- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { // Restrict user in entering 25 characters in UITextField
if (textField.tag==111) {
const char * _char = [string cStringUsingEncoding:NSUTF8StringEncoding];
int isBackSpace = strcmp(_char, "\b");
if (isBackSpace == -8) {
NSLog(@"isBackSpace");
return YES; // is backspace
}
else if (textField.text.length <= 25 && range.length == 0) {
return YES;
}
}
return NO;
}
No comments:
Post a Comment