我想只使用字母键盘,如何限制它?我使用了以下语句,但它没有隐藏按键转换数字键盘的按钮
tempTextField.keyboardType = UIKeyboardTypeAlphabet;
Run Code Online (Sandbox Code Playgroud)
drv*_*ijk 10
我很害怕你不能将键盘限制为只输入字母字符.可用的keyboardTypes列在UITextInputTraits协议引用中,并且在头文件中有更多详细信息:
typedef enum {
UIKeyboardTypeDefault, // Default type for the current input method.
UIKeyboardTypeASCIICapable, // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
UIKeyboardTypeNumbersAndPunctuation, // Numbers and assorted punctuation.
UIKeyboardTypeURL, // A type optimized for URL entry (shows . / .com prominently).
UIKeyboardTypeNumberPad, // A number pad (0-9). Suitable for PIN entry.
UIKeyboardTypePhonePad, // A phone pad (1-9, *, 0, #, with letters under the numbers).
UIKeyboardTypeNamePhonePad, // A type optimized for entering a person's name or phone number.
UIKeyboardTypeEmailAddress, // A type optimized for multiple email address entry (shows space @ . prominently).
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated
} UIKeyboardType;
Run Code Online (Sandbox Code Playgroud)
我觉得SDK中缺少你想要的东西.我会向Apple提交一个错误报告,请求新的键盘类型,就像你提到的那样.
除了提交错误报告并等待新的键盘类型在SDK中可用之外,还有什么解决方案?检查文本字段中的输入.这可以通过分配UITextField的delegate属性并实现UITextFieldDelegate方法textField:shouldChangeCharactersInRange:replacementString:来完成,如果替换字符串不包含数字,则只返回YES.
HTH
| 归档时间: |
|
| 查看次数: |
13470 次 |
| 最近记录: |