UITextField输入到最大限值以后不能删除

转自:http://blog.csdn.net/linkai5696/article/details/5742421

解决UITextField输入到最大值不能删除的现象:

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    BOOL isAllowEdit = YES;
    if([string length]>range.length&&[textField.text length]+[string length]-range.length>_NAME_MAX_LENGTH_)
    {
        [textField resignFirstResponder];
        isAllowEdit = NO;
    }
    return isAllowEdit;
}


你可能感兴趣的:(UITextField输入到最大限值以后不能删除)