Xcode - 使用 UIDatePicker 时以葡萄牙语显示月份名称
我正在使用 UIDatePicker
,我想用巴西葡萄牙语显示月份名称。我已经尝试使用 timeZone
属性,但没有成功。
这是我的代码:
UIDatePicker *pv = [[UIDatePicker alloc] initWithFrame:CGRectMake(0,0,320,216)];
pv.datePickerMode = UIDatePickerModeDate;
pv.timeZone = [NSTimeZone timeZoneWithName:@"America/Sao_Paulo"];
有人会帮助我吗?
I am using the UIDatePicker
and I'd like to show month names in Brazilian Portuguese. I've already tried to use the timeZone
property, no success though.
Here is my code:
UIDatePicker *pv = [[UIDatePicker alloc] initWithFrame:CGRectMake(0,0,320,216)];
pv.datePickerMode = UIDatePickerModeDate;
pv.timeZone = [NSTimeZone timeZoneWithName:@"America/Sao_Paulo"];
Does anybody would help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将选择器上的区域设置属性设置为您想要的区域设置,如下所示:
它应该正确配置自身。您可能需要检查
[NSLocale availableLocaleIdentifiers]
以确定您想要的区域设置是否可用/已安装。Set the locale property on the picker to the locale you want, like this:
It should configure itself correctly. You may need to check
[NSLocale availableLocaleIdentifiers]
to determine if the locale you want is available/installed.需要澄清。您是否只想将日期选择器设置为葡萄牙语,并将应用程序的其余部分保留为用户的默认语言?
通常,
datepicker
会根据用户按照settings/general/international
下的设置更改语言。datepicker
将自动调整为用户所需的语言,因此您不必直接对其进行本地化。Clarification needed. Do you only want to set the date picker to Portuguese, and keep the rest of the app in the user's default language?
Normally the
datepicker
changes language with the user following the settings undersettings/general/international
. Thedatepicker
will automatically adjust to the user's desired language, so you don't have to localize it directly.你不需要做任何事。一旦 iPhone 设置为正确的区域设置,
UIDatePicker
就会为您显示正确的值。这就是不推荐使用与区域设置相关的方法和属性的原因。它依赖于系统配置。You don't have to do anything. As soon as the iPhone is set to the proper locale, the
UIDatePicker
will show the proper values for you. That's why locale related methods and properties are deprecated. It relies on system configuration.