iphone – 获取IOS时区更改的通知

当设备时区改变时,我的应用程序能否得到任何通知?当我的应用程序是前台时,我想收到通知. 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进行发布,以获取与您应用中其他地方相同的信息.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...