我的应用程序可以在设备时区更改时收到任何通知吗?我想在我的应用程序处于前台时收到通知.NSTimezone 对我不起作用,因为我必须不断检查时区.
can my application get any notification when device timezone changed? I want to get a notification when my application is foreground. NSTimezone does not worked for me as i have to continuously check for timezone.
UIApplicationDelegate
有一个名为 applicationSignificantTimeChange:
的方法,当时间发生重大变化时会调用该方法.
UIApplicationDelegate
has a method called applicationSignificantTimeChange:
that gets called when there is a significant change in the time.
文档中列出的示例是:
重大时间变化的示例包括午夜的到来、运营商的时间更新以及夏令时的变化
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
但我认为时区变化算作重大的时间变化.
But I would assume that timezone changes count as a significant time change.
文档还说,如果在您的应用处于后台时发生时间变化,您将在您转到前台时得到它
The docs also say that if the time change happens when your app is in the background you will get it when you go to the foreground
如果您的应用程序当前处于挂起状态,则此消息将排队等待您的应用程序返回到前台,此时它会被传递.
If your application is currently suspended, this message is queued until your application returns to the foreground, at which point it is delivered.
您还可以侦听要发布的 UIApplicationSignificantTimeChangeNotification
以在您应用的其他任何地方获取相同的信息.
You can also listen for UIApplicationSignificantTimeChangeNotification
to be posted to get the same information anywhere else in your app.
这篇关于在 iOS 中获取有关时区更改的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!