TextField编辑中状态判读

来源:互联网 发布:新郎西服软件 编辑:程序博客网 时间:2024/06/08 02:12
//textfield有输入时判断两个textfield中是否为空,控制按钮的点击状态
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{    NSLog(@"%@", string);    NSLog(@"lo = %i", range.location);    NSLog(@"le = %i", range.length);        NSInteger tag = [textField tag];        BOOL bIsOk = true;        if (tag == 0)    {        if (self.mPassWordTF.text.length == 0 || (range.length == 1 && range.location == 0))        {            bIsOk = false;        }    }    else if (tag == 1)    {        if ((range.length == 1 && range.location == 0) || self.mNameTF.text.length == 0)        {            bIsOk = false;        }    }        self.navigationItem.rightBarButtonItem.enabled = bIsOk;        return YES;}


0 0
原创粉丝点击