Joh*_*ang 29
或者,在代码中设置textfield的keyboardType属性:
textField.keyboardType = UIKeyboardTypeNumberPad
Run Code Online (Sandbox Code Playgroud)
可用选项包括:
UIKeyboardType为给定的基于文本的视图显示的键盘类型.
typedef enum {
UIKeyboardTypeDefault,
UIKeyboardTypeASCIICapable,
UIKeyboardTypeNumbersAndPunctuation,
UIKeyboardTypeURL,
UIKeyboardTypeNumberPad,
UIKeyboardTypePhonePad,
UIKeyboardTypeNamePhonePad,
UIKeyboardTypeEmailAddress,
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable} UIKeyboardType;
但值得注意的是,NumberPad没有小数点可供输入.如果你需要,你将不得不使用其他东西.
| 归档时间: |
|
| 查看次数: |
29729 次 |
| 最近记录: |