UIKeyboardTypeDecimalPad 本地化

发布于 2024-09-25 21:49:19 字数 247 浏览 8 评论 0原文

我注意到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

牛↙奶布丁 2024-10-02 21:49:19

从 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 ","

你爱我像她 2024-10-02 21:49:19

解决这个问题的一种方法是只接受标点符号,因为它是小数点,然后在将其作为字符串传递以显示时更改它。

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

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

如果您只需要显示,这将起作用。如果您用该字符串进行数学运算,它将不起作用。你实际上不能。现在您可以将其存储为浮点数,然后当您转换为字符串时,您可以执行这两行代码

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文