![](/img/trans.png)
[英]How Can I show keyboard appears on label touch in tableview( iphone)
[英]How can I show the numeric keyboard by default on iPhone?
我正在尝试以下但没有运气。 当用户单击 UiTextfield 时,我需要将键盘视图自动更改为数字视图,这可能吗?
UITextInputTraits
协议( UITextField
符合)具有类型为UIKeyboardType
的keyboardType
属性。
myTextField.keyboardType = UIKeyboardTypeNumberPad;
UITextField符合UITextInputTraits协议,这意味着它具有您可以设置的keyboardType属性。
myField.keyboardType = UIKeyboardTypeNumberPad;
您也可以通过界面构建器进行设置。 从文本输入特性设置键盘到数字键盘,这就是全部。
如果要显示数字键盘但还需要能够使用小数点,货币符号或其他字符,则可以将键盘默认设置为字母键盘的背面。
currentTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
这是一个很好的做法,总是写父类UIKeyboardType
,然后继续键盘枚举numberPad
myTextField.keyboardType = UIKeyboardType.numberPad
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.