开发者

UIDatePicker locale does nothing?

开发者 https://www.devze.com 2022-12-27 14:59 出处:网络
I\'m creating a UIDatePicker programmatically, and setting its locale with the following code: 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, o开发者_StackOverflow中文版r how to fix it?


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.


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]; 
0

精彩评论

暂无评论...
验证码 换一张
取 消