当第一个字符键盘自动被解除后尝试输入文本字段时,我没有实现任何文本字段代理,shouldChangeCharacterInRange
除外,在此方法中没有resignFirstResponder
或endEditing
并且没有禁用textFields。
if ([theTextField isEqual:_userName]) {
MAX_DIGITS = 15;
NSCharacterSet *myCharSet = [NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ0123456789-._"];
for (int i = 0; i < [string length]; i++) {
unichar c = [string characterAtIndex:i];
if (![myCharSet characterIsMember:c]) {
return NO;
} else {
return [theTextField.text stringByReplacingCharactersInRange:range withString:string].length <= MAX_DIGITS;
}
}
}
retutn YES: