首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我可以在iPad上使用哪个UIKeyboardType

我可以在iPad上使用哪个UIKeyboardType
EN

Stack Overflow用户
提问于 2012-07-26 00:12:39
回答 2查看 14K关注 0票数 8

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

代码语言:javascript
复制
UITextField *textField = [[UITextField alloc] initWithFrame:frame];
textField.keyboardType = UIKeyboardTypeDecimalPad;

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

代码语言:javascript
复制
textField.keyboardType = UIKeyboardTypePhonePad;

键盘如下所示:

理想情况下,我想要一个只有数字和小数点的键盘,但这在iPad上是不可能的吗?有没有人知道哪些键盘可以在iPhone上使用,哪些可以在iPad上使用?苹果在这一点上并不清楚。我也看到了这个question,它很相似,但没有一个答案真正解决了我的问题。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-07-26 01:38:07

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

  • UIKeyboardTypeDefault

代码语言:javascript
复制
- Use the default keyboard for the current input method.
- Available in iOS 2.0 and later.
- Declared in `UITextInputTraits.h`.

  • UIKeyboardTypeASCIICapable

代码语言:javascript
复制
- Use a keyboard that displays standard ASCII characters.
- Available in iOS 2.0 and later.
- Declared in `UITextInputTraits.h`.

  • UIKeyboardTypeNumbersAndPunctuation

代码语言:javascript
复制
- Use the numbers and punctuation keyboard.
- Available in iOS 2.0 and later.
- Declared in `UITextInputTraits.h`.

  • UIKeyboardTypeURL

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

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

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

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

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

代码语言:javascript
复制
- Use a keyboard with numbers and a decimal point.
- Available in iOS 4.1 and later.
- Declared in `UITextInputTraits.h`.

  • UIKeyboardTypeTwitter

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

代码语言:javascript
复制
- Deprecated.
- Use UIKeyboardTypeASCIICapable instead.
- Available in iOS 2.0 and later.
- Declared in `UITextInputTraits.h`.

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

票数 11
EN

Stack Overflow用户

发布于 2013-07-17 20:06:26

在收到警告后,我使用模拟器测试了哪些键盘类型可用于iPad/iPhone

使用2592645918_Wildcat-Alphabetic-Keyboard_Capital-Letters“时,

”找不到支持键盘类型8的键盘

UIKeyboardTypeDecimalPad的iPad上。希望这对下一个在这里跌跌撞撞的人有用。

iPad:

  • UIKeyboardTypeASCIICapable
  • UIKeyboardTypeNumbersAndPunctuation
  • UIKeyboardTypeURL
  • UIKeyboardTypeNumberPad
  • UIKeyboardTypeNamePhonePad
  • UIKeyboardTypeEmailAddress
  • UIKeyboardTypeTwitter

所以,除了UIKeyboardTypeDecimalPad之外的所有人。在iOS 5.1或6.1中,使用UIKeyboardTypeDecimalPad只会给你一记耳光。

iPhone:

  • UIKeyboardTypeASCIICapable
  • UIKeyboardTypeNumbersAndPunctuation
  • UIKeyboardTypeURL
  • UIKeyboardTypeNumberPad
  • UIKeyboardTypeNamePhonePad
  • UIKeyboardTypeEmailAddress
  • UIKeyboardTypeDecimalPad
  • UIKeyboardTypeTwitter

也就是说,它们全部

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

https://stackoverflow.com/questions/11654101

复制
相关文章

相似问题

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