Which UIKeyboardType can I use on the iPad

I have a textField object in an app for iPad. I would like to give the user a convenient keyboard for entering numbers. In my code, I added:

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

According to the docs, this is a valid keyboard type, but when I edit a text box, a regular ASCII keyboard appears. However, when I change it to:

 textField.keyboardType = UIKeyboardTypePhonePad; 

The keyboard looks like this: phonepad keyboard

Ideally, I would like the keyboard to have only numbers and a decimal point, but is this impossible on the iPad? Does anyone have a definitive list of which keyboards work on iPhone vs iPad? Apple is unclear. I also saw this question , which is similar, but none of the answers touch my point.

Thanks!

+7
source share
2 answers

These are UIKeyboardTypes that can be used on both iOS devices. From 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 numbers and a punctuation keyboard.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h .

  • UIKeyboardTypeURL

    • Use a keyboard optimized for entering URLs. This type has the form ".", "/" And ".com".
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h .

  • UIKeyboardTypeNumberPad

    • Use the numeric keypad to enter your PIN. This type shows numbers from 0 to 9. This type of keyboard does not support automatic capitalization.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h .

  • UIKeyboardTypePhonePad

    • Use the keypad for entering phone numbers. This type contains numbers from 0 to 9 and the characters "*" and "#" are noticeable. This type of keyboard does not support automatic capitalization.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h .

  • UIKeyboardTypeNamePhonePad

    • Use the keyboard to enter a name or phone number. This type of keyboard does not support automatic capitalization.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h .

  • UIKeyboardTypeEmailAddress

    • Use a keyboard optimized for typing email addresses. This type has the functions "@", "." and space symbols are noticeable.
    • Available in iOS 2.0 and later.
    • Declared in UITextInputTraits.h .

  • UIKeyboardTypeDecimalPad

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

  • UIKeyboardTypeTwitter

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

  • UIKeyboardTypeAlphabet

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

Here are some screenshots of various types of keyboards .

+10
source

I tested which types of keyboards are available for iPad / iPhone using Simulator after receiving a warning

"Cannot find a keyboard that supports Type 8 for the Wildcat-QWERTY-Pad; using 2592645918_Wildcat-Alphabetical-Keyboard_Capital-letter"

on iPad for UIKeyboardTypeDecimalPad . Hope this is helpful for the next person who stumbles here.

IPad:

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

So everything except UIKeyboardTypeDecimalPad . using the UIKeyboardTypeDecimalPad , you only get helmets on your wrist in iOS 5.1 or 6.1.

iPhone:

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

i.e. all of them

+5
source

All Articles