iPhone:在UITextField上禁用自动上限/自动更正的问题 [英] iPhone: Issue disabling Auto-Cap/autocorrect on a UITextField

查看:105
本文介绍了iPhone:在UITextField上禁用自动上限/自动更正的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,即使我禁用了我的UITextField的自动上限和自动更正,它仍然将我输入的第一个字母大写。

For some reason, even though I disable the auto-cap and auto-correct of my UITextField, it's still capitalizing the first letter of my input.

这是代码:

UITextField* textField = [[[UITextField alloc] initWithFrame:CGRectMake(90.0, 10.0, 213.0, 25.0)] autorelease];
[textField setClearButtonMode:UITextFieldViewModeWhileEditing];
textField.returnKeyType = UIReturnKeyGo;
textField.autocorrectionType = FALSE;
textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
textField.delegate = self;
if (inputFieldType == Email) {
    label.text = @"Email:";
    textField.keyboardType = UIKeyboardTypeEmailAddress;
    emailTextField  = textField;
    textField.placeholder = @"Email Address";
} else { // password
    textField.secureTextEntry = TRUE;
    label.text = @"Password:";
    if (inputFieldType == Password){
        textField.placeholder = @"Password";
        passwordTextField  = textField;
    }
    if (inputFieldType == ConfirmPassword){
        textField.placeholder = @"Confirm Password";
        confirmPasswordTextField  = textField;
    }

}

查看截图:
替代文字http://grab.by/39WE

推荐答案

您将 autocorrectionType 设置为 FALSE ,就好像它是 BOOL ,但实际上它的类型为 UITextAutocorrectionType 。所以 FALSE 被解释为 UITextAutocorrectionTypeDefault ,这意味着可能启用了自动更正。

You're setting autocorrectionType to FALSE as if it were a BOOL, but it actually has type UITextAutocorrectionType. So FALSE is being interpreted as UITextAutocorrectionTypeDefault, which means that autocorrection is probably enabled.

我打赌它在你的地址簿中找到了名字Phil,并且自动修正大写以匹配。

I bet it found the name "Phil" in your address book and is autocorrecting the capitalization to match.

这篇关于iPhone:在UITextField上禁用自动上限/自动更正的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆