views:

2421

answers:

4

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

+2  A: 
typedef enum {
   UIKeyboardTypeDefault,
   UIKeyboardTypeASCIICapable,
   UIKeyboardTypeNumbersAndPunctuation,
   UIKeyboardTypeURL,
   UIKeyboardTypeNumberPad,
   UIKeyboardTypePhonePad,
   UIKeyboardTypeNamePhonePad,
   UIKeyboardTypeEmailAddress,
   UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable
} 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

sbwoodside
A: 

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.

shek
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
A: 

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

Frank Schmitt
+1  A: 

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.

Not needed?

I would use it in EVERY textfield that needs a dollars/cents value.... and every decimal value.

Donna