UI键盘类型

UIkeyboard type(UI键盘类型)
本文介绍了UI键盘类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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

I want to use only alphabetic keyboard, how to restrict it? I've used following statement but it doesn't hide the button that converts keyboard in numeric one

tempTextField.keyboardType = UIKeyboardTypeAlphabet;    

推荐答案

恐怕您不能将键盘限制为只能输入字母字符.UITextInputTraits 协议参考中列出了可用的键盘类型,并且在头文件中提供了更多详细信息:

I'm affraid you cannot restrict the keyboard to only input alphabetic characters. The available keyboardTypes are listed in the UITextInputTraits protocol reference, and with even more detail in the header file:

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 中缺少您想要的东西.我会向 Apple 提交一份错误报告,要求使用新的键盘类型,就像你提到的那样.

I feel what you want is missing from the SDK. I would file a bug report with Apple requesting a new keyboard type, like the one you mentioned.

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

What is the solution for you besides filing a bug report and waiting for your new keyboard type to become available in the SDK? Checking the input in the textfield. This can be done by assigning the delegate property of the UITextField, and implementing the UITextFieldDelegate method textField:shouldChangeCharactersInRange:replacementString: and only return YES if the replacement string does not contain numbers.

HTH

这篇关于UI键盘类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)