NSLocaleUsesMetricSystem 在 iPad 上始终为 YES
我试图确定用户的区域/区域设置是否验证公制值的使用(在这种情况下,是否应附加 kg 或 lb)。
我在 iPad 和模拟器上运行 3.2(Xcode 3.2.4)。 我已经尝试了一些不同的区域设置,但我根本无法让它返回 NO
对于 NSLocaleUsesMetricSystem
NSLocale *locale = [NSLocale systemLocale];
BOOL usesMetric = [[locale objectForKey:NSLocaleUsesMetricSystem] boolValue];
NSLog(@"The system is Metric: %@\n", (usesMetric ? @"YES" : @"NO"));
这甚至发生在语言设置为 English 和在模拟器和实际设备上将区域设置为美国。
我还尝试了 NSLocaleMeasurementSystem ,它也总是返回“公制”,而不是“美国”。
我将如何决定是否应该使用公制?
感谢您提供的任何帮助:)
...我是否很幸运,在我睡觉时整个世界都变成了公制:)
I am trying to decide if the users Region/Locale settings validates the use of Metric values (in this case if kg or lb should be appended).
I am running 3.2 on my iPad and on the simulator(Xcode 3.2.4).
I have tried out a few different Region settings but I simply can not make it return NO
for NSLocaleUsesMetricSystem
NSLocale *locale = [NSLocale systemLocale];
BOOL usesMetric = [[locale objectForKey:NSLocaleUsesMetricSystem] boolValue];
NSLog(@"The system is Metric: %@\n", (usesMetric ? @"YES" : @"NO"));
This even happens for language set to English and region set to United States on both the simulator and on the actual device.
I also tried NSLocaleMeasurementSystem
and it too always returns "Metric", never "U.S.".
How will I go about deciding if I should use Metric or not?
Thanks for any help given:)
...could I be so lucky that the whole world changed to metric while I was sleeping:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用
currentLocale
而不是systemLocale
Try
currentLocale
instead ofsystemLocale
遇到了同样的问题,直到我意识到,英国正式使用公制。我一直以为他们还是用英制,所以我测试了英国。
当我开始测试美国语言环境时,NSLocaleUsesMetricSystem 开始按预期返回“NO”。
希望这有帮助。
Had the same problem, until I realized, that UK officially uses metric system. I have always thought that they still use imperial, so I tested with UK.
As soon as I started to test US locale, NSLocaleUsesMetricSystem started to return "NO" as expected.
Hope this helps.