UIDatePicker locale does nothing?

前端 未结 2 912
难免孤独
难免孤独 2021-01-21 02:25

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

datePicker.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@\         


        
相关标签:
2条回答
  • 2021-01-21 02:54

    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 讨论(0)
  • 2021-01-21 03:09

    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.

    0 讨论(0)
提交回复
热议问题