-1

When using the UIKeyboardTypeNumberPad option, the button in the bottom left will be a ",". But I want a ".", not a ",". Is it possible to change this?

  • Can I add an extra button to the NumberPad?
  • Or can I change every "," with a "."?
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278

1 Answers1

1

The decimal keypad shows either a period or a comma depending on the user's locale as set in the Region Format setting in the Settings app (Settings -> General -> International).

You don't want to force a period. Users in locales that expect a comma want to see a comma.

If you need to convert a user-entered number string into a number, use NSNumberFormatter to do so. This will properly deal with the user's locale and number format.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • I am using the textField's text to transform to a floatValue and the problem is that decimal numbers won't be registered when using a "," but it will when using a ".". – user3000356 Dec 03 '13 at 20:15
  • 1
    That's why I said you need to use an `NSNumberFormatter` to convert the user-entered text into a number value. The number formatter will know how to deal with the comma or period based on the user's locale. – rmaddy Dec 03 '13 at 20:17
  • BTW - your original question is the wrong question. The question should not have been about changing the decimal key on the keypad. Your question should have been about converting such user-entered values into `float` numbers. – rmaddy Dec 03 '13 at 20:19
  • Thanks for the quick responses guys! I have none experience with NSNumberFormatter, how can I adjust it without using storyboard? – user3000356 Dec 03 '13 at 20:55