12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- //
- // UserRegisterAccountViewController.m
- // XenonSDK
- //
- // Created by SAGESSE on 2019/5/29.
- // Copyright © 2019 SAGESSE. All rights reserved.
- //
- #import "XenonSDK.h"
- #import "UserRegisterAccountViewController.h"
- #import "NSBundle+KODLocalizable.h"
- #import "KODCommonConst.h"
- @interface UserRegisterAccountViewController ()
- @end
- @implementation UserRegisterAccountViewController
- -(void)viewDidLoad {
-
- self.view.backgroundColor = [UIColor whiteColor];
- self.accountTextField.textColor = [UIColor blackColor];
- self.passwordTextField.textColor = [UIColor blackColor];
- }
- - (void)registerForPassword:(id)sender {
- // Resign editing.
- [self.view endEditing:YES];
-
- // Must enter account.
- NSString* account = self.accountTextField.text;
- if (account.length == 0) {
- //请输入帐号
- NSString *str = [NSBundle KOD_localizedStringForKey:PleaseEnterAccount];
- [XSNetwork showHudFailure:str];
- return;
- }
-
- // Must enter password.
- NSString* password = self.passwordTextField.text;
- if (password.length == 0) {
- //请输入密码
- NSString *str = [NSBundle KOD_localizedStringForKey:PleaseEnterPwd];
- [XSNetwork showHudFailure:str];
- return;
- }
-
- [XSNetwork showHudLoading];
- [XSNetwork registerWithAccount:account password:password complete:^(id object, NSError *error) {
-
- if (error != nil) {
- [XSNetwork showHudFailure:error];
- return;
- }
-
- if (XenonSDK.sharedSDK.sdk_loginCallback) {
- XenonSDK.sharedSDK.sdk_loginCallback(object);
- }
- }];
- }
- - (void)displayModeForPassword:(UIButton*)sender {
- // Toggle password display mode.
- sender.selected = !sender.selected;
- self.passwordTextField.secureTextEntry = sender.selected;
- }
- // MARK: -
- - (BOOL)textFieldShouldReturn:(UITextField *)textField {
-
- if (textField.returnKeyType == UIReturnKeyDone) {
- [self registerForPassword:textField];
- return NO;
- }
-
- if (textField == self.accountTextField) {
- [self.passwordTextField becomeFirstResponder];
- }
-
- return YES;
- }
- @end
|