如何在 UITextField 的默认键盘中显示数字
在我的 iPhone 应用程序中,我有一个地址行 1 字段。我已为其指定了默认键盘。但最有可能的是,第 1 行字段将以公寓号开头。
我想知道如何最初在该字段的默认键盘中显示数字。
In my iPhone application I have an address line 1 field. I have assigned the default keyboard to that. But most likely line 1 field will start with apartment number.
I want to know how to show numbers in the default keyboard initially for this field.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能需要使用 UIKeyboardTypeNumbersAndPunctuation 来代替,因为输入街道号码后,用户可以返回字母键盘(通过按键盘底部的“ABC”按钮)。如果使用数字键盘,则只能输入数字。
要在 IB 中执行此操作,请打开检查器并选择它作为默认键盘。要以编程方式执行此操作,只需添加
textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
You may want to use
UIKeyboardTypeNumbersAndPunctuation
instead, since the user can then go back to the alphabetical keyboard (by pressing the "ABC" button on the bottom of the keyboard) once the street number is entered. If you use the numberPad, only numbers can be entered.To do this in IB, open the Inspector and select this as the default keypad. To do this programmatically, just add
textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
尝试使用这个......
Try using this........
将 textField.inputView 设置为
按照本教程设置“完成”按钮!
http://www.neoos.ch /news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key
Set you textField.inputView as
Follow this tutorial for setting up a 'DONE' button !
http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key