ios - 我可以在 iPad 上使用哪种 UIKeyboardType

标签 ios objective-c ipad uikeyboardtype

我的 iPad 应用程序中有一个 textField 对象。我想给用户一个方便的键盘来输入数字。在我的代码中,我添加了:

UITextField *textField = [[UITextField alloc] initWithFrame:frame];
textField.keyboardType = UIKeyboardTypeDecimalPad;

根据文档,这是一种有效的键盘类型,但当我编辑文本字段时,会出现普通的 ASCII 键盘。但是,当我将其更改为:

textField.keyboardType = UIKeyboardTypePhonePad;

键盘看起来像这样: phonepad keyboard

理想情况下,我想要一个只有数字和小数点的键盘,但这在 iPad 上是不可能的吗?有没有人有关于哪些键盘适用于 iPhone 和 iPad 的明确列表?苹果在这一点上并不清楚。我也看到了这个question这是相似的,但没有一个答案真正解决了我的观点。

最佳答案

这些是可以在两种 iOS 设备上使用的 UIKeyboardTypes。来自 the docs :

  • UIKeyboardTypeDefault

    • Use the default keyboard for the current input method.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h.

  • UIKeyboardTypeASCIICapable

    • Use a keyboard that displays standard ASCII characters.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h.

  • UIKeyboardTypeNumbersAndPunctuation

    • Use the numbers and punctuation keyboard.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h.

  • UIKeyboardTypeURL

    • Use a keyboard optimized for URL entry. This type features “.”, “/”, and “.com” prominently.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h.

  • UIKeyboardTypeNumberPad

    • Use a numeric keypad designed for PIN entry. This type features the numbers 0 through 9 prominently. This keyboard type does not support auto-capitalization.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h.

  • UIKeyboardTypePhonePad

    • Use a keypad designed for entering telephone numbers. This type features the numbers 0 through 9 and the “*” and “#” characters prominently. This keyboard type does not support auto-capitalization.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h.

  • UIKeyboardTypeNamePhonePad

    • Use a keypad designed for entering a person’s name or phone number. This keyboard type does not support auto-capitalization.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h.

  • UIKeyboardTypeEmailAddress

    • Use a keyboard optimized for specifying email addresses. This type features the “@”, “.” and space characters prominently.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h.

  • UIKeyboardTypeDecimalPad

    • Use a keyboard with numbers and a decimal point.
    • Available in iOS 4.1 and later.
    • Declared in UITextInputTraits.h.

  • UIKeyboardTypeTwitter

    • Use a keyboard optimized for twitter text entry, with easy access to the @ and # characters.
    • Available in iOS 5.0 and later.
    • Declared in UITextInputTraits.h.

  • UIKeyboardTypeAlphabet

    • Deprecated.
    • Use UIKeyboardTypeASCIICapable instead.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h.

这里有一些 screenshots of the different types of keyboards .

关于ios - 我可以在 iPad 上使用哪种 UIKeyboardType,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11654101/

相关文章:

ios - 照片的JPEG NSData转UIImage转JPEG大小完全不同

iphone - UIScrollview subview 超出剪切范围未接收触摸

iphone - NSMutableArray 排序问题

ios - iOS 9 未显示启动屏幕

ios - 定义委托(delegate)属性时的 id 与类名

ios - 来自 AVMetadataItem objective-c 的 ISRC 代码

升级到 xcode 4.3.2 后,iOS 模拟器不再连接到网络 midi

ios - 为什么更新我的 UIView 有延迟

ios - 使用我自己的 UICollectionViewFlowLayout 子类滚动时,UICollectionView 项目消失

java - Obj-c 委托(delegate)模型 - 在 Java 中?