iOS App开发中UITextField组件的常用属性小结

2020-01-14 22:24:55王冬梅

            }
        }
    }
}
为当前的view增加点击事件
复制代码
UITapGestureRecognizer *dismissKeyboardTap = [[UITapGestureRecognizer alloc]                                                initWithTarget:self                                                 action:@selector(dismissKeyboard)];
[self.view addGestureRecognizer: dismissKeyboardTap];

 

二、为内容增加校验

复制代码
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
    switch (textField.tag) {
        case 100://name
        {
            NSLog(@"this is nameField");
            //添加校验name的代码
            break;
        }
        case 101://phone
        {
            NSLog(@"this is phoneField");
            //添加校验phone的代码
            break;
        }
        case 102://email
        {
            NSLog(@"this is emailField");
            //添加校验email的代码
            break;
        }        
        default:
            break;
    }
    return YES;
}
 

注:相关教程知识阅读请移步到IOS开发频道。