Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
657 views
in Technique[技术] by (71.8m points)

iphone - Show Time in 12 and 24 hour format in UIDatepicker on the basis of app settings not on device Settings

My problem is there is a switch in my app which toggles for 12 hour and 24 hour time format.I am displaying my labels time according to that, but the UIDatePicker time is not getting changed.It's time is depending on device time settings format.Is it possible to show time in UIDatePicker according to my app settings which might be different from device time settings. Somewhere I read that UIDatePicker respects only device settings but still I want to ask if it is possible to show time in 12 and 24 hour format in UIDatePicker based on my app settings.

Please help me. Any suggestions would be highly appreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try this code to show 24 Hrs Format in DatePicker:

NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"NL"];
[self.datePicker setLocale:locale];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...