首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIkeyboard类型

UIkeyboard类型
EN

Stack Overflow用户
提问于 2009-07-13 06:44:15
回答 2查看 13.8K关注 0票数 6

我想只使用字母键盘,怎么限制它?我使用了以下语句,但它没有隐藏将键盘转换为数字键盘的按钮

代码语言:javascript
复制
tempTextField.keyboardType = UIKeyboardTypeAlphabet;    
EN

回答 2

Stack Overflow用户

发布于 2009-07-13 07:08:20

恐怕你不能限制键盘只输入字母字符。UITextInputTraits协议参考中列出了可用的keyboardTypes,头文件中列出了更详细的信息:

代码语言:javascript
复制
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;

我觉得SDK中缺少您想要的东西。

除了提交错误报告并等待新的键盘类型在SDK中可用之外,您还有什么解决方案?检查文本字段中的输入。这可以通过分配UITextField的委托属性并实现UITextFieldDelegate方法textField:shouldChangeCharactersInRange:replacementString:来实现,并且只有在替换字符串不包含数字时才返回YES。

HTH

票数 10
EN

Stack Overflow用户

发布于 2013-03-13 14:49:48

更新后的键盘类型

代码语言:javascript
复制
   typedef NS_ENUM(NSInteger, UIKeyboardType) {
        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).
    #if __IPHONE_4_1 <= __IPHONE_OS_VERSION_MAX_ALLOWED
        UIKeyboardTypeDecimalPad,             // A number pad with a decimal point.
    #endif
    #if __IPHONE_5_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED
        UIKeyboardTypeTwitter,                // A type optimized for twitter text entry (easy access to @ #)
    #endif

        UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated

    };
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1117980

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档