123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- //
- // EditMySignOrBriefVC.m
- // smartRhino
- //
- // Created by armin on 2019/11/1.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "EditMySignOrBriefVC.h"
- #import "UIPlaceHolderTextView.h"
- @interface EditMySignOrBriefVC ()<UITextViewDelegate>
- @property (strong,nonatomic) IBOutlet UILabel *pageTitleLabel;
- @property (strong,nonatomic) IBOutlet UIButton *okBtn;
- @property (strong,nonatomic) IBOutlet UIPlaceHolderTextView *editTextView;
- @end
- @implementation EditMySignOrBriefVC
- +(EditMySignOrBriefVC *)initEditMySignOrBriefVC{
- EditMySignOrBriefVC *controller = [StoryboardManager.shared.myCenter instantiateViewControllerWithIdentifier:@"EditMySignOrBriefVC"];
- return controller;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.fd_prefersNavigationBarHidden = YES;
- self.editTextView.delegate = self;
- if(self.pagetype == EditMySignOrBriefPageType1){
- self.pageTitleLabel.text = @"我的签名";
- self.editTextView.text = [AppUserModel sharedAppUserModel].Signature;
- if (self.editTextView.text.length == 0) {
- self.editTextView.placeholder = @"我的签名";
- }
- }else if(self.pagetype == EditMySignOrBriefPageType2){
- self.pageTitleLabel.text = @"自我介绍";
- self.editTextView.text = [AppUserModel sharedAppUserModel].Description;
- if (self.editTextView.text.length == 0) {
- self.editTextView.placeholder = @"自我介绍";
- }
- }else{
- self.pageTitleLabel.text = @"我的昵称";
- self.editTextView.text = [AppUserModel sharedAppUserModel].Nick;
- if (self.editTextView.text.length == 0) {
- self.editTextView.placeholder = @"我的昵称";
- }
- }
- NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
- paragraphStyle.lineSpacing = 12;// 字体的行间距
- NSDictionary *attributes = @{
- NSFontAttributeName:[UIFont systemFontOfSize:16],
- NSParagraphStyleAttributeName:paragraphStyle
- };
- self.editTextView.typingAttributes = attributes;
-
- WEAKSELF
- [self.okBtn setAction:^{
- STRONGSELF
-
- if(strongSelf.pagetype == EditMySignOrBriefPageType1){
- [strongSelf commitData];
- }else if(strongSelf.pagetype == EditMySignOrBriefPageType2){
- [strongSelf commitData2];
- }else{
- [strongSelf commitData3];
- }
- }];
-
- }
- - (void)commitData{
- WEAKSELF
- SHOWLOADING
- NSString *modyUrl = [NSString stringWithFormat:@"%@%@",BaseUrl,UpdateUserInfoPUT];
- [[HttpManager sharedHttpManager] PUTUrl:modyUrl parameters:@{@"signature":self.editTextView.text} success:^(id _Nonnull responseObject) {
- [UserManager getUserInfoDetailSuccess:^(id _Nonnull responseObject) {
- REMOVESHOW
- STRONGSELF
- [strongSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- NSLog(@"成功");
-
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- NSLog(@"失败");
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- }
- - (void)commitData2{
- if (self.editTextView.text.length == 0) {
- SHOWERROR(@"内容不能为空");
- return;
- }
- WEAKSELF
- SHOWLOADING
- NSString *modyUrl = [NSString stringWithFormat:@"%@%@",BaseUrl,UpdateUserInfoPUT];
- [[HttpManager sharedHttpManager] PUTUrl:modyUrl parameters:@{@"description":self.editTextView.text} success:^(id _Nonnull responseObject) {
- [UserManager getUserInfoDetailSuccess:^(id _Nonnull responseObject) {
- REMOVESHOW
- STRONGSELF
- [strongSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- NSLog(@"成功");
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- NSLog(@"失败");
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- }
- - (void)commitData3{
- WEAKSELF
- SHOWLOADING
- NSString *modyUrl = [NSString stringWithFormat:@"%@%@",BaseUrl,UpdateUserInfoPUT];
- [[HttpManager sharedHttpManager] PUTUrl:modyUrl parameters:@{@"Nick":self.editTextView.text} success:^(id _Nonnull responseObject) {
- [UserManager getUserInfoDetailSuccess:^(id _Nonnull responseObject) {
- REMOVESHOW
- STRONGSELF
- [strongSelf.navigationController popViewControllerAnimated:YES];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- NSLog(@"成功");
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- NSLog(@"失败");
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- }
- /****************************************************/
- #pragma mark - UITextViewDelegate
- /****************************************************/
- - (void)textViewDidEndEditing:(UITextView *)textView{
- NSLog(@"%@",textView.text);
- }
- - (void)textViewDidChange:(UITextView *)textView
- {
- if (textView.text.length > 500) {
- textView.text = [textView.text substringToIndex:500];
- }
- // self.textLengthLabel.text = [NSString stringWithFormat:@"%lu/500",(unsigned long)textView.text.length];
- }
- - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
- NSString *tempString = [textView.text stringByReplacingCharactersInRange:range withString:text];
- if (tempString.length > 500) {
- textView.text = [tempString substringToIndex:500];
- return NO;
- }
- return YES;
- }
- /*
- #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
|