我的iPad应用程序中有一个textField对象。我想给用户一个方便的键盘来输入数字。在我的代码中,我添加了:
UITextField *textField = [[UITextField alloc] initWithFrame:frame];
textField.keyboardType = UIKeyboardTypeDecimalPad;根据文档,这是一个有效的键盘类型,但当我编辑文本字段时,会出现正常的ASCII键盘。但是,当我将其更改为:
textField.keyboardType = UIKeyboardTypePhonePad;键盘如下所示:

理想情况下,我想要一个只有数字和小数点的键盘,但这在iPad上是不可能的吗?有没有人知道哪些键盘可以在iPhone上使用,哪些可以在iPad上使用?苹果在这一点上并不清楚。我也看到了这个question,它很相似,但没有一个答案真正解决了我的问题。
发布于 2012-07-26 01:38:07
这些是可以在两个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。
发布于 2013-07-17 20:06:26
在收到警告后,我使用模拟器测试了哪些键盘类型可用于iPad/iPhone
使用2592645918_Wildcat-Alphabetic-Keyboard_Capital-Letters“时,
”找不到支持键盘类型8的键盘
在UIKeyboardTypeDecimalPad的iPad上。希望这对下一个在这里跌跌撞撞的人有用。
iPad:
所以,除了UIKeyboardTypeDecimalPad之外的所有人。在iOS 5.1或6.1中,使用UIKeyboardTypeDecimalPad只会给你一记耳光。
iPhone:
也就是说,它们全部
https://stackoverflow.com/questions/11654101
复制相似问题