How to stop entering value in UITextField
How to stop entering value in UITextField if t开发者_如何学Gohe length is greater then 20 char.
Programmatically.
try this
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
//Set tag for a textfield
if(textField.tag==10)
{
NSUInteger newLength = [textField.text length] + [string length] - range.length;
return (newLength > 20) ? NO : YES;
}
}
Set the maximum character length of a UITextField
精彩评论