UserRegisterAccountViewController.m 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // UserRegisterAccountViewController.m
  3. // XenonSDK
  4. //
  5. // Created by SAGESSE on 2019/5/29.
  6. // Copyright © 2019 SAGESSE. All rights reserved.
  7. //
  8. #import "XenonSDK.h"
  9. #import "UserRegisterAccountViewController.h"
  10. @interface UserRegisterAccountViewController ()
  11. @end
  12. @implementation UserRegisterAccountViewController
  13. - (void)registerForPassword:(id)sender {
  14. // Resign editing.
  15. [self.view endEditing:YES];
  16. // Must enter account.
  17. NSString* account = self.accountTextField.text;
  18. if (account.length == 0) {
  19. [XSNetwork showHudFailure:@"请输入帐号"];
  20. return;
  21. }
  22. // Must enter password.
  23. NSString* password = self.passwordTextField.text;
  24. if (password.length == 0) {
  25. [XSNetwork showHudFailure:@"请输入密码"];
  26. return;
  27. }
  28. [XSNetwork showHudLoading];
  29. [XSNetwork registerWithAccount:account password:password complete:^(id object, NSError *error) {
  30. if (error != nil) {
  31. [XSNetwork showHudFailure:error];
  32. return;
  33. }
  34. if (XenonSDK.sharedSDK.sdk_loginCallback) {
  35. XenonSDK.sharedSDK.sdk_loginCallback(object);
  36. }
  37. }];
  38. }
  39. - (void)displayModeForPassword:(UIButton*)sender {
  40. // Toggle password display mode.
  41. sender.selected = !sender.selected;
  42. self.passwordTextField.secureTextEntry = sender.selected;
  43. }
  44. // MARK: -
  45. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  46. if (textField.returnKeyType == UIReturnKeyDone) {
  47. [self registerForPassword:textField];
  48. return NO;
  49. }
  50. if (textField == self.accountTextField) {
  51. [self.passwordTextField becomeFirstResponder];
  52. }
  53. return YES;
  54. }
  55. @end