UITextField setAutocapitalizationType 奇怪的行为

发布于 2024-09-12 00:35:12 字数 725 浏览 4 评论 0原文

我有两个 XIB 生成的 UITextFields,我在 -viewWillAppear: 中有条件地配置它们,如下所示:

//Configure text fields
[emailField setDelegate:self];
[emailField setKeyboardType:UIKeyboardTypeEmailAddress];
[emailField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[emailField setAutocorrectionType:UITextAutocorrectionTypeNo];
[nameField setDelegate:self];
[nameField setKeyboardType:UIKeyboardTypeAlphabet];
[nameField setAutocapitalizationType:UITextAutocapitalizationTypeWords];
[nameField setAutocorrectionType:UITextAutocorrectionTypeNo];

emailField 行为正常。 nameField 表现正常,但有一个例外:

当 nameField 成为第一响应者时,通过调用 -becomeFirstResponder 或点击该字段,Shift/Caps 按钮会突出显示(如预期),并针对后续字符关闭(如预期),但没有字符实际上都是大写的。

I've got two XIB-generated UITextFields that I'm conditionally configuring in -viewWillAppear: as follows:

//Configure text fields
[emailField setDelegate:self];
[emailField setKeyboardType:UIKeyboardTypeEmailAddress];
[emailField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[emailField setAutocorrectionType:UITextAutocorrectionTypeNo];
[nameField setDelegate:self];
[nameField setKeyboardType:UIKeyboardTypeAlphabet];
[nameField setAutocapitalizationType:UITextAutocapitalizationTypeWords];
[nameField setAutocorrectionType:UITextAutocorrectionTypeNo];

emailField behaves normally. nameField behaves normally with one exception:

When nameField becomes the First Responder, either by calling -becomeFirstResponder or by tapping in the field, the Shift/Caps button highlights (as expected), and turns off for subsequent characters (as expected), but no characters are ever actually capitalized.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

囍笑 2024-09-19 00:35:12

酷,我是个白痴。

此行为发生在模拟器中,我正在使用 Mac 键盘输入文本。当然,它不会资本化。

单击模拟器中的键盘按键会产生正确的结果,就像在设备上运行应用程序一样。

希望其他人可以解决这个问题。

(:麦基:)

Cool, I was being an idiot.

This behavior was taking place in the simulator, and I was using my Mac's keyboard to enter the text. Of course it wasn't going to capitalize.

Clicking on the keyboard keys in the simulator produced proper results, as did running the app on-device.

Hope someone else can save a headache with this.

(:Mikey:)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文