13

How can I get the numeric keyboard with the decimal separator? Currently I am stuck with UIKeyboardNumberPad.

John Smith
  • 12,491
  • 18
  • 65
  • 111

4 Answers4

11

you can try this

UIKeyboardTypeDecimalPad

deck john
  • 637
  • 1
  • 9
  • 22
7
typedef enum {
   UIKeyboardTypeDefault,
   UIKeyboardTypeASCIICapable,
   UIKeyboardTypeNumbersAndPunctuation,
   UIKeyboardTypeURL,
   UIKeyboardTypeNumberPad,
   UIKeyboardTypePhonePad,
   UIKeyboardTypeNamePhonePad,
   UIKeyboardTypeEmailAddress,
   UIKeyboardTypeDecimalPad,
   UIKeyboardTypeTwitter,
   UIKeyboardTypeWebSearch,
   UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable // Deprecated
} UIKeyboardType;

If you don't like those, you can always modify them in code...

http://openradar.appspot.com/6635276

This has a solution: http://www.iphonedevsdk.com/forum/iphone-sdk-development/6573-howto-customize-uikeyboard.html

zvjerka24
  • 1,772
  • 1
  • 21
  • 27
Simon Woodside
  • 7,175
  • 5
  • 50
  • 66
  • 15
    I know this is an old topic, but anyone who comes across this should note that as of iOS 4.1, there is a new UIKeyboardType defined in that enum called UIKeyboardTypeDecimalPad. – Alex Robinson Feb 11 '11 at 12:58
  • 1
    Is there any good solution if you would like to be able to enter positive and negative decimal numbers? – nj. Oct 26 '12 at 12:12
1

The UIKeyboardTypeNumbersAndPunctuation is probably the least-bad option, unless you have the time and resources to roll your own keyboard.

Frank Schmitt
  • 25,648
  • 10
  • 58
  • 70
0

The iPhone SDK currently does not offer a keypad (0-9) + decimal button UIKeyboard. I suspect this was designed because for the majority of use cases, it is not needed.

See this previous StackOverflow question discussing the (lack of) need for a decimal separator for currency inputs. I also wrote a blog post about this very topic.

However, if you really do need a keypad + decimal button keyboard, your only option will be to roll your own custom keyboard. Contrary sbwoodside's answer, you really want to shy away from customizing the existing UIKeyboard. While this may be easy to do, it relies upon private classes that can change anytime...meaning your hack could break in the future without warning.

Community
  • 1
  • 1
shek
  • 12,721
  • 2
  • 26
  • 23
  • Unfortunately in my case I am not dealing with fixed decimal places so I really do need a decimal point. Your solution on your blog post does now work. Your solution here would only work in certain situations. – John Smith Aug 23 '09 at 18:21