| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- //
- // YOUPAILCUpdateRecomIdVC.m
- // LiveChat
- //
- // Created by 张灿 on 2018/4/14.
- // Copyright © 2018年 caicai. All rights reserved.
- //
- #import "YOUPAILCUpdateRecomIdVC.h"
- @interface YOUPAILCUpdateRecomIdVC ()<UITextFieldDelegate>
- @property(nonatomic,strong)UITextField* youpaiptextField;
- @end
- @implementation YOUPAILCUpdateRecomIdVC
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
- // self.sx_disableInteractivePop = NO;
- }
- - (void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
- [self.youpaiptextField becomeFirstResponder];
- self.sx_disableInteractivePop = YES;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"推荐人花舞号";
- [self youpaifsetupView];
- self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifbackNeedSave) image:[UIImage imageNamed:@"nav_back_normal"]];
- }
- - (void)youpaifbackNeedSave{
- if ([self.youpaiptextField.text isEqualToString:self.youpaiprecomId] && (![self.youpaiptextField.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.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(SaveRemark) title:@"保存" font:LCFont12 titleColor:LCGray highlightedColor:LCGray 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];
-
- UITextField* textField = [[UITextField alloc]initWithFrame:CGRectMake(16,30, KScreenWidth-32, 45)];
- textField.backgroundColor = [UIColor whiteColor];
- textField.layer.cornerRadius = 8;
- textField.layer.masksToBounds = YES;
- textField.delegate = self;
- textField.text = self.youpaiprecomId;
- textField.font = [UIFont systemFontOfSize:12];
- textField.textColor = HexColorFromRGB(0x333333);
- textField.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 19, 45)];
- textField.leftViewMode = UITextFieldViewModeAlways;
- textField.clearButtonMode = UITextFieldViewModeAlways;
- [[textField valueForKey:@"_clearButton"] setImage:[UIImage imageNamed:@"vqu_images_D_nick_clean"] forState:UIControlStateNormal];
- textField.placeholder = @"输入推荐人花舞号";
- textField.keyboardType = UIKeyboardTypeNumberPad;
- self.youpaiptextField = textField;
- [scrollView addSubview:textField];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaiftextDidChange) name:UITextFieldTextDidChangeNotification object:textField];
-
- }
- - (void)youpaiftextDidChange{
- NSLog(@"%@",self.youpaiptextField.text);
- if ([self.youpaiptextField.text isEqualToString:self.youpaiprecomId]) {
-
- self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifSaveRemark) title:@"保存" font:LCFont12 titleColor:LCGray highlightedColor:LCGray titleEdgeInsets:UIEdgeInsetsZero];
- self.navigationItem.rightBarButtonItem.enabled = NO;
- }else{
- self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifSaveRemark) title:@"保存" font:LCFont12 titleColor:ZYPinkColor highlightedColor:ZYPinkColor titleEdgeInsets:UIEdgeInsetsZero];
- self.navigationItem.rightBarButtonItem.enabled = YES;
-
- }
- if(self.youpaiptextField.text.length>11){
- self.youpaiptextField.text = [self.youpaiptextField.text substringToIndex:11];
- }
- }
- - (void)youpaifSaveRemark{
- if (self.youpaipblock) {
- self.youpaipblock(self.youpaiptextField.text);
- }
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)dealloc
- {
- [[NSNotificationCenter defaultCenter]removeObserver:self name:UITextViewTextDidChangeNotification object:self.youpaiptextField];
- }
- @end
|