8

I have a a textField object in my iPad app. 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 the text field the normal ASCII keyboard comes up. However, when I change it to:

textField.keyboardType = UIKeyboardTypePhonePad;

The keyboard looks like this: phonepad keyboard

Ideally I would like a keyboard that only has the numbers and decimal point but is this not possible on the iPad? Does anyone have a definitive list of which keyboards work on the iPhone vs. iPad? Apple is unclear on this point. I also saw this question which is similar but none of the answers really address my point.

StaceyGirl
  • 6,826
  • 12
  • 33
  • 59
Samantha John
  • 957
  • 1
  • 7
  • 18

2 Answers2

11

These are the 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 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.

Here are some screenshots of the different types of keyboards.

Andrew Marshall
  • 89,426
  • 20
  • 208
  • 208
Midhun MP
  • 90,682
  • 30
  • 147
  • 191
  • 10
    Hmm, **UIKeyboardTypeDecimalPad** definitely doesn't work on iPad while some of the other ones produce the same keyboard. i.e. **UIKeyboardTypePhonePad** and **UIKeyboardTypeNumberPad** are the same as far as I can tell. I'd be interested to see a comprehensive list of keyboards that are actually available on iPad. – Samantha John Jul 25 '12 at 20:10
  • @SamanthaJohn: available list is added on the top of the answer. I tried this **UIKeyboardTypeDecimalPad** on ipad simulator and it worked for me. – Midhun MP Jul 26 '12 at 15:51
  • Oh you're right, it's working for me now. I think ultimately I'll have to roll my own keyboard though since it doesn't seem that Apple gives many default options for iPad. (Just the numbers or the letters and you can always switch between). – Samantha John Aug 27 '12 at 14:37
  • 4
    Strange, **UIKeyboardTypeDecimalPad** doesn't work on any device/simulator I tried. Xcode was kind enough to say this: _Can't find keyplane that supports type 8 for keyboard Wildcat-Landscape-QWERTY-Pad; using 2592645918_Wildcat-Alphabetic-Keyboard_Capital-Letters_ – ArkReversed May 24 '13 at 11:14
  • I can say that there's not a lot of keyboard types available on the iPad (iOS 10.3) and if they are available they are only a different starting view that you can swap back, it won't limit input. I was looking for a way to limit input to number only except those keyboards aren't available on iPad, works great on iPhone though. – Tristan Sep 18 '17 at 14:05
6

I tested which keyboard types are available for iPad/iPhone using the Simulator after receiving the warning

"Can't find keyplane that supports type 8 for keyboard Wildcat-Landscape-QWERTY-Pad; using 2592645918_Wildcat-Alphabetic-Keyboard_Capital-Letters"

on the iPad for the UIKeyboardTypeDecimalPad. Hopefully this is useful for the next person that stumbles here.

iPad:

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

So, all of them except UIKeyboardTypeDecimalPad. using UIKeyboardTypeDecimalPad gets you nothing but a slap on the wrist in either iOS 5.1 or 6.1.

iPhone:

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

i.e. all of them

Matt Jacobsen
  • 5,604
  • 3
  • 33
  • 46