【发布时间】:2011-09-08 05:56:08
【问题描述】:
在我的 iPhone 应用程序中,我有一个地址行 1 字段。我已经为其分配了默认键盘。但最有可能的第 1 行字段将以公寓号开头。
我想知道如何在这个字段的默认键盘中显示数字。
【问题讨论】:
标签: iphone keyboard numbers uitextfield
在我的 iPhone 应用程序中,我有一个地址行 1 字段。我已经为其分配了默认键盘。但最有可能的第 1 行字段将以公寓号开头。
我想知道如何在这个字段的默认键盘中显示数字。
【问题讨论】:
标签: iphone keyboard numbers uitextfield
您可能想改用UIKeyboardTypeNumbersAndPunctuation,因为一旦输入了街道号码,用户就可以返回到字母键盘(通过按键盘底部的“ABC”按钮)。如果使用数字键盘,则只能输入数字。
要在 IB 中执行此操作,请打开 Inspector 并选择它作为默认键盘。要以编程方式执行此操作,只需添加 textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
【讨论】:
尝试使用这个............
[textField becomeFirstResponder];
textField.keyboardType = UIKeyboardTypeNumberPad;
【讨论】:
将你的 textField.inputView 设置为
textField.inputView = nil;
[textField setKeyboardType:UIKeyboardTypeNumberPad];
按照本教程设置“完成”按钮!
http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key
【讨论】: