123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- //
- // YOUPAILZUpdateSignVC.m
- // MEISHI
- //
- // Created by CY on 2021/1/12.
- // Copyright © 2021 leo. All rights reserved.
- //
- #import "YOUPAILZUpdateSignVC.h"
- #import "YOUPAILZTextView.h"
- @interface YOUPAILZUpdateSignVC ()
- @property(nonatomic,strong)YOUPAILZTextView *youpaiptextView;
- @end
- @implementation YOUPAILZUpdateSignVC
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
- // self.sx_disableInteractivePop = NO;
- }
- - (void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
- [self.youpaiptextView.youpaiptextView becomeFirstResponder];
- self.sx_disableInteractivePop = YES;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self youpaifsetupView];
- self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifbackNeedSave) image:[UIImage imageNamed:@"vqu_images_navigation_back_black"]];
- }
- - (void)youpaifbackNeedSave{
- if ([self.youpaiptextView.youpaiptextView.text isEqualToString:self.youpaipsign] && (![self.youpaiptextView.youpaiptextView.text isEqualToString:@""])) {
- [self.navigationController popViewControllerAnimated:YES];
- }else{
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"保存信息" message:@"是否保存本次修改内容?" preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"不保存" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
- [self.navigationController popViewControllerAnimated:YES];
- }];
- UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"保存" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
- [self youpaifSaveRemark];
- }];
- [alertController addAction:cancelAction];
- [alertController addAction:okAction];
- [self presentViewController:alertController animated:YES completion:nil];
- }
- }
- - (void)youpaifsetupView{
- //设置导航栏
- self.title = @"个人介绍";
- self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifSaveRemark) title:@"保存" font:LCFont15 titleColor:LZA3AABEColor highlightedColor:LZA3AABEColor titleEdgeInsets:UIEdgeInsetsZero];
- self.navigationItem.rightBarButtonItem.enabled = NO;
- //设置textView
- UIScrollView* scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenHeight-NavBarHeight)];
- scrollView.contentSize = CGSizeMake(KScreenWidth, KScreenHeight-NavBarHeight+1);
- scrollView.bounces = YES;
- scrollView.showsHorizontalScrollIndicator = NO;
- scrollView.showsVerticalScrollIndicator = NO;
- [self.view addSubview:scrollView];
- self.view.backgroundColor = [UIColor whiteColor];
-
- YOUPAILZTextView *textView = [[YOUPAILZTextView alloc] initWithMaxCount:100];
- textView.frame = CGRectMake(14, 25, KScreenWidth-28, 139);
- textView.youpaiptextViewPadding = UIEdgeInsetsMake(14.0f, 14.0f, 10.0f, 14.0f);
- textView.youpaiptextLengthDefaultColor = LZD3D1D7Color;
- textView.youpaiptextLengthHigtColor = LZ7C69FEColor;
- textView.youpaiptextLengthFont = LCFont(14.0f);
- textView.youpaiptextLengthRight = 14.0f;
- textView.youpaiptextLengthBottom = 14.0f;
- textView.youpaiptextView.placeholderFont = LCFont(14.0f);
- textView.youpaiptextView.placeholderTextColor = LZF7F8FAColor;
- textView.youpaiptextView.placeholderText = @"简单介绍一下自己吧…";
- textView.youpaiptextView.font = LCFont(14.0f);
- textView.layer.cornerRadius = 5.0f;
- textView.clipsToBounds = YES;
- textView.tintColor = LZ7C69FEColor;
- [scrollView addSubview:textView];
- textView.youpaiptextView.textColor = LZ273145Color;
- self.youpaiptextView = textView;
- textView.backgroundColor = LZF7F8FAColor;
- textView.youpaiptextView.text = self.youpaipsign;
-
- [RACObserve(textView.youpaiptextView, text) subscribeNext:^(id _Nullable x) {
- if ([x isEqualToString:self.youpaipsign]) {
- self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifSaveRemark) title:@"保存" font:LCFont15 titleColor:LZA3AABEColor highlightedColor:LZA3AABEColor titleEdgeInsets:UIEdgeInsetsZero];
- self.navigationItem.rightBarButtonItem.enabled = NO;
- }else{
- self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifSaveRemark) title:@"保存" font:LCFont15 titleColor:LZ7C69FEColor highlightedColor:LZ7C69FEColor titleEdgeInsets:UIEdgeInsetsZero];
- self.navigationItem.rightBarButtonItem.enabled = YES;
-
- }
- }];
- }
- ////在这个地方计算输入的字数
- //- (void)textViewDidChange:(UITextView *)textView{
- //
- // if ([textView.text isEqualToString:self.youpaipsign]) {
- // self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifSaveRemark) title:@"保存" font:LCFont15 titleColor:HexColorFromRGB(0x9F9DA5) highlightedColor:HexColorFromRGB(0x9F9DA5) titleEdgeInsets:UIEdgeInsetsZero];
- // self.navigationItem.rightBarButtonItem.enabled = NO;
- // }else{
- // self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifSaveRemark) title:@"保存" font:LCFont15 titleColor:ZYPinkColor highlightedColor:ZYPinkColor titleEdgeInsets:UIEdgeInsetsZero];
- // self.navigationItem.rightBarButtonItem.enabled = YES;
- //
- // }
- //}
- - (void)youpaifSaveRemark{
- //加一个正则判断昵称是否符合规则 正则限制/[\x{4e00}-\x{9fa5}\w]+$/u 长度限制2~12个utf8字符
- // if (self.textField.text.length<1 || self.textField.text.length>10) {
- // [ZCHUDHelper showTitle:@"昵称长度为1~10个字符"];
- // }else{
- [LCHttpHelper requestWithURLString:UpdateUserMsg parameters:@{@"signature":self.youpaiptextView.youpaiptextView.text}
- needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- YOUPAILCUserModel* userModel = [LCSaveModel getUserModel];
- userModel.youpaipuserinfo.youpaipsign = self.youpaiptextView.youpaiptextView.text;
- [LCSaveModel saveUserModel:userModel];
-
- if (self.youpaipblock) {
- self.youpaipblock(self.youpaiptextView.youpaiptextView.text);
- }
- [self.navigationController popViewControllerAnimated:YES];
- }
- } failure:^(NSError *error) {
- }];
- // }
- }
- @end
|