当设备时区改变时,我的应用程序能否得到任何通知?当我的应用程序是前台时,我想收到通知. NSTimezone不适合我,因为我必须不断检查时区.
解决方法
UIApplicationDelegate有一个名为applicationSignificantTimeChange的方法:当时间有重大变化时被调用.
文档中列出的示例如下:
Examples of significant time changes include the arrival of midnight,an update of the time by a carrier,and the change to daylight savings time
但是我认为时区变化是一个重大的时间变化.
该文档还会说,如果您的应用程序在后台时间更改发生,您会得到它,当你去前台
If your application is currently suspended,this message is queued until your application returns to the foreground,at which point it is delivered.
您也可以听UIApplicationSignificantTimeChangeNotification进行发布,以获取与您应用中其他地方相同的信息.