// // EditUserNickVC.m // smartRhino // // Created by armin on 2019/11/1. // Copyright © 2019 tederen. All rights reserved. // #import "EditUserNickVC.h" @interface EditUserNickVC () @property (strong,nonatomic) IBOutlet UIButton *okBtn; @property (strong,nonatomic) IBOutlet UITextField *editTextField; @end @implementation EditUserNickVC +(EditUserNickVC *)initEditUserNickVC{ EditUserNickVC *controller = [StoryboardManager.shared.myCenter instantiateViewControllerWithIdentifier:@"EditUserNickVC"]; return controller; } - (void)viewDidLoad { [super viewDidLoad]; self.fd_prefersNavigationBarHidden = YES; self.okBtn.layer.masksToBounds = YES; self.okBtn.layer.cornerRadius = 4.0; self.editTextField.delegate = self; self.editTextField.text =[AppUserModel sharedAppUserModel].Name; self.editTextField.placeholder = @"请输入昵称"; self.editTextField.clearButtonMode = UITextFieldViewModeAlways; WEAKSELF [self.okBtn setAction:^{ STRONGSELF NSLog(@"点击了"); [strongSelf ModyUserNick]; }]; } - (void)ModyUserNick{ SHOWLOADING WEAKSELF NSString *modyUrl = [NSString stringWithFormat:@"%@%@%@",BaseUrl,UpdateUserInfoPUT,kToken]; [[HttpManager sharedHttpManager] PUTUrl:modyUrl parameters:@{@"Name":self.editTextField.text} success:^(id _Nonnull responseObject) { REMOVESHOW STRONGSELF [strongSelf.navigationController popViewControllerAnimated:true]; } failure:^(NSError * _Nonnull error) { REMOVESHOW SHOWERROR([ZYCTool handerResultData:error]) }]; } /****************************************************/ #pragma mark - UITextFieldDelegate /****************************************************/ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{ NSString *tempString = [textField.text stringByReplacingCharactersInRange:range withString:string]; if ([string isEqualToString:@""] || [string isEqualToString:@"\n"]) { return YES; } return YES; } - (void)textFieldDidEndEditing:(UITextField *)textField{ } -(void)textFieldDidChange:(UITextField *)textField{ if (textField.text.length > 20) { textField.text = [textField.text substringToIndex:20]; } } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end