键盘在iOS 11.2.6

时间:2018-04-16 11:18:33

标签: objective-c uitextfield

当第一个字符键盘自动被解除后尝试输入文本字段时,我没有实现任何文本字段代理,shouldChangeCharacterInRange除外,在此方法中没有resignFirstResponderendEditing并且没有禁用textFields。

if ([theTextField isEqual:_userName]) {
        MAX_DIGITS = 15;
        NSCharacterSet *myCharSet = [NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ0123456789-._"];
        for (int i = 0; i < [string length]; i++) {
            unichar c = [string characterAtIndex:i];
            if (![myCharSet characterIsMember:c]) {
                return NO;
            } else {
                return [theTextField.text stringByReplacingCharactersInRange:range withString:string].length <= MAX_DIGITS;
            }
        }
    }

retutn YES:

0 个答案:

没有答案