NSLocaleUsesMetricSystem 在 iPad 上始终为 YES

发布于 2024-09-28 10:57:30 字数 654 浏览 0 评论 0原文

我试图确定用户的区域/区域设置是否验证公制值的使用(在这种情况下,是否应附加 kglb)。

我在 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 技术交流群。

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

发布评论

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

评论(2

把回忆走一遍 2024-10-05 10:57:30

尝试使用 currentLocale 而不是 systemLocale

Try currentLocale instead of systemLocale

聚集的泪 2024-10-05 10:57:30

遇到了同样的问题,直到我意识到,英国正式使用公制。我一直以为他们还是用英制,所以我测试了英国。

当我开始测试美国语言环境时,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.

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