How can I get the numeric keyboard with the decimal separator? Currently I am stuck with UIKeyboardNumberPad.
4 Answers
you can try this
UIKeyboardTypeDecimalPad

- 637
- 1
- 9
- 22
-
Thanks, this makes life much easier. – John Smith Aug 08 '12 at 15:11
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

- 1,772
- 1
- 21
- 27

- 7,175
- 5
- 50
- 66
-
15I 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
-
1Is 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
The UIKeyboardTypeNumbersAndPunctuation
is probably the least-bad option, unless you have the time and resources to roll your own keyboard.

- 25,648
- 10
- 58
- 70
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.
-
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