UIKeyboardTypeDecimalPad 本地化
我注意到 iOS 4.1 中添加了 UIKeyboardTypeDecimalPad,并开始使用它。在测试过程中,我在“设置”的“国际”部分将语言和区域切换为法语。我预计应用程序键盘上的小数键将从“.”更改为“。”到一个“,”,但事实并非如此。
我所做的就是:
_textFieldUnitCost.keyboardType = UIKeyboardTypeDecimalPad;
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 4.2.1 开始,键盘上的小数键现在从“.”更改为“。”当切换到使用“,”的语言/区域时,转换为“,”
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.
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