textField到相应字段执行方法

来源:互联网 发布:蝙蝠侠 英勇无畏 知乎 编辑:程序博客网 时间:2024/06/04 19:50
[_tel_tf addTarget:self action:@selector(textFiledDidChange:) forControlEvents:UIControlEventEditingChanged];
- (void) textFiledDidChange:(UITextField *)text
{
if( _tel_tf.text.length == 11){
[_tel_tf restorationIdentifier];
tele = [NSString stringWithString:_tel_tf.text];
//须知行的方法
}
}
//限制舒服字符的长度
- (BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
//用户名
if (textField == _tel_tf) {
if (_tel_tf.text.length > 6) {
if (string.length > 0) {
return NO;
}else{
return YES;
}
}
}
return YES;
}
0 0
原创粉丝点击