Question

I noticed that UIKeyboardTypeDecimalPad was added in iOS 4.1, and started using it. During the course of my testing, I switched both the language and region to French in the International section of Settings. I expected the decimal key on the keypad in my app to change from a "." to a "," but it didn't.

All I'm doing is this:

_textFieldUnitCost.keyboardType = UIKeyboardTypeDecimalPad;

Any ideas?

Was it helpful?

Solution

As of 4.2.1 the decimal key on the keypad now changes from a "." to "," when switching to a language/region that uses a ","

OTHER TIPS

One way around it is to just accept the punctuation because it is a decimalpad and than change it when you pass it as a string to display.

NSString *firstString = @"102.08", *finalString;

finalString = [[firstString stringByReplacingOccurancesOfString:@"." withString:@","];
//string value returns 102,08

That will work if you just need to display. It will not work if your doing math with that string. You actually can't. Now you can store it as a float and then when you convert to a string you do those 2 lines of code

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top