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?
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 ","
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
精彩评论