1.规定输入内容的长度
//限制输入框中输入内容的长度
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
if (self.phoneNumTextField.text.length == 11) {
if ([string isEqualToString:@""]) {
return YES;
}
else {
return NO;
}
}
return YES;
}
网友评论