NSDateFormatter - 将设备语言设置为区域设置?

发布于 2024-09-04 07:06:43 字数 457 浏览 6 评论 0原文

我试图让 iPhone 以当前设备语言显示由 NSDateFormatter 格式化的日期。

我尝试过 setLocale:[NSLocale currentLocale],但只返回 5 而不是 May (或 Mai,正如我所希望的那样)。

编辑currentLocale显示五月(英语)。 systemLocale 显示 5(我认为 systemLocale 是挪威语),autoupdatingCurrentLocale 也显示 May

任何帮助表示赞赏。谢谢! :)

没关系 - 模拟器对我开了个玩笑,它可以在真实设备上运行。 #

I'm trying to get the iPhone to display dates formatted by an NSDateFormatter in the current device language.

I have tried setLocale:[NSLocale currentLocale], but that only returns 5 instead of May (or Mai, as I want it to be).

EDIT: currentLocale shows May (english). systemLocale shows 5 (I think systemLocale is Norwegian), and autoupdatingCurrentLocale shows May as well.

Any help is appreciated. Thanks! :)

NEVERMIND - The simulator played a trick with me, it works on a real device. #

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

深海蓝天 2024-09-11 07:06:43

我忘记将区域格式设置为我的本地区域格式:)

I had forgotten to set the Region Format to my local region format :)

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