UIDatePicker 语言环境什么都不做?

发布于 2024-08-29 05:43:50 字数 220 浏览 2 评论 0原文

我正在以编程方式创建 UIDatePicker,并使用以下代码设置其区域设置:

datePicker.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"es_ES"] autorelease];

日期选择器仍然以英语显示(或我将手机设置为的任何语言)。任何人都知道为什么这不起作用,或者如何解决它?

I'm creating a UIDatePicker programmatically, and setting its locale with the following code:

datePicker.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"es_ES"] autorelease];

The datepicker still appears in English (or whatever language I've set the phone to). Anyone have any idea why this does nothing, or how to fix it?

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

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

发布评论

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

评论(2

乖乖哒 2024-09-05 05:43:50

正如此处回答的我可以本地化 UIDatePicker 吗?,选择器显示取决于取决于国家/地区设置,而不是语言设置。

在您的示例中,您仅更改语言区域设置。

As answered here Can I localize a UIDatePicker?, the picker display depends on country settings, not on language settings.

In your example you are changing the language locale only.

浪漫之都 2024-09-05 05:43:50

尝试更改 UIDatePicker 日历的区域设置:

NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"es_ES"] autorelease];
datePicker.locale = locale; 
datePicker.calendar = [locale objectForKey:NSLocaleCalendar]; 

Try changing the locale of the UIDatePicker's calendar as well:

NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"es_ES"] autorelease];
datePicker.locale = locale; 
datePicker.calendar = [locale objectForKey:NSLocaleCalendar]; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文