How to create Time Zone selection like Settings ap

2019-06-20 07:07发布

I am trying to achieve a selection table view like the one in the Settings app for selecting time zone in an iOS app, where the time zones are displayed with a nicely formatted City and Country name.

From the documentation, the + (NSArray *)knownTimeZoneNames method returns all the "ID"s of the time zones, in alphabetical order but not in "time" order, and those names are quite ugly to read such as America/New_York. All the other methods in NSTimeZone return the localized names such as “Central Standard Time” for Central Time. However those names means nothing for most of the users, as they are used to reason in terms of "cities" instead than in terms of "time zones" (especially in Europe).

Is there a way to achieve the same representation as the one in Settings app using NSTimeZone own methods, or should I build a database of time zones and cities myself?

Settings App time zones example

0条回答
登录 后发表回答