Float is not recognizing numbers with a "," between it

117 views Asked by At

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 "."?
1

There are 1 answers

4
rmaddy On

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.