UITextField autocapitalizationType UITextAutocapitalizationTypeAllCharacters不在设备上工作 [英] UITextField autocapitalizationType UITextAutocapitalizationTypeAllCharacters not working on device

查看:339
本文介绍了UITextField autocapitalizationType UITextAutocapitalizationTypeAllCharacters不在设备上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以设置UITextField的autocapitalizationType属性,以便所有输入都是大写的。我发现在模拟器上工作正常(实际上是在点击模拟器的键盘,而不是Mac的键盘),而不是在设备上?一切都保持小写。

You can set the autocapitalizationType property of a UITextField so all input is in upper case. I find that does work fine on the simulator (when actually tapping the simulator's keypad, not the Mac's keyboard), but not on the device? Everything stays lowercase.

在UICatalog演示中,我添加了textFieldNormal方法:

In the UICatalog demo I added to the textFieldNormal method:

textFieldNormal.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;

也添加了一个委托,以显示UITextField的实际autocapitalizationType:

Added a delegate too, to display the actual autocapitalizationType for the UITextField:

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    NSLog( @"textField.autocapitalizationType=%d", textField.autocapitalizationType );
}

它将正确显示3(= UITextAutocapitalizationTypeAllCharacters),但您点击的任何内容仍为小写。我缺少什么?

It will properly display 3 (=UITextAutocapitalizationTypeAllCharacters), but anything you tap remains lowercase. What am I missing?

推荐答案

显然这是设备常规设置问题:设置 - >常规 - >键盘 - >自动 - 大写必须为ON才能将textField.autocapitalizationType设置为全部大写,否则显然会忽略设置属性。如果我打开它,一切都按预期工作。

Apparently this is a device general settings issue: Settings -> General -> Keyboard -> Auto-Capitalization must be ON to honour the setting of textField.autocapitalizationType to all upper case, else setting the property is ignored, apparently. If I switch it on everything works as expected.

这篇关于UITextField autocapitalizationType UITextAutocapitalizationTypeAllCharacters不在设备上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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