- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (range.location >= 10)//限制长度不超过10
return NO; // return NO to not change text
return YES;
}
转自:http://www.cocoachina.com/bbs/read.php?tid=29494&page=1#193273