EditUserNickVC.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // EditUserNickVC.m
  3. // smartRhino
  4. //
  5. // Created by armin on 2019/11/1.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "EditUserNickVC.h"
  9. @interface EditUserNickVC ()<UITextFieldDelegate>
  10. @property (strong,nonatomic) IBOutlet UIButton *okBtn;
  11. @property (strong,nonatomic) IBOutlet UITextField *editTextField;
  12. @end
  13. @implementation EditUserNickVC
  14. +(EditUserNickVC *)initEditUserNickVC{
  15. EditUserNickVC *controller = [StoryboardManager.shared.myCenter instantiateViewControllerWithIdentifier:@"EditUserNickVC"];
  16. return controller;
  17. }
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. self.fd_prefersNavigationBarHidden = YES;
  21. self.okBtn.layer.masksToBounds = YES;
  22. self.okBtn.layer.cornerRadius = 4.0;
  23. self.editTextField.delegate = self;
  24. self.editTextField.text =[AppUserModel sharedAppUserModel].Name;
  25. self.editTextField.placeholder = @"请输入昵称";
  26. self.editTextField.clearButtonMode = UITextFieldViewModeAlways;
  27. WEAKSELF
  28. [self.okBtn setAction:^{
  29. STRONGSELF
  30. NSLog(@"点击了");
  31. [strongSelf ModyUserNick];
  32. }];
  33. }
  34. - (void)ModyUserNick{
  35. SHOWLOADING
  36. WEAKSELF
  37. NSString *modyUrl = [NSString stringWithFormat:@"%@%@%@",BaseUrl,UpdateUserInfoPUT,kToken];
  38. [[HttpManager sharedHttpManager] PUTUrl:modyUrl parameters:@{@"Name":self.editTextField.text} success:^(id _Nonnull responseObject) {
  39. REMOVESHOW
  40. STRONGSELF
  41. [strongSelf.navigationController popViewControllerAnimated:true];
  42. } failure:^(NSError * _Nonnull error) {
  43. REMOVESHOW
  44. SHOWERROR([ZYCTool handerResultData:error])
  45. }];
  46. }
  47. /****************************************************/
  48. #pragma mark - UITextFieldDelegate
  49. /****************************************************/
  50. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
  51. NSString *tempString = [textField.text stringByReplacingCharactersInRange:range withString:string];
  52. if ([string isEqualToString:@""] || [string isEqualToString:@"\n"]) {
  53. return YES;
  54. }
  55. return YES;
  56. }
  57. - (void)textFieldDidEndEditing:(UITextField *)textField{
  58. }
  59. -(void)textFieldDidChange:(UITextField *)textField{
  60. if (textField.text.length > 20) {
  61. textField.text = [textField.text substringToIndex:20];
  62. }
  63. }
  64. /*
  65. #pragma mark - Navigation
  66. // In a storyboard-based application, you will often want to do a little preparation before navigation
  67. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  68. // Get the new view controller using [segue destinationViewController].
  69. // Pass the selected object to the new view controller.
  70. }
  71. */
  72. @end