get notification on timezone change in iOS(在 iOS 中获取有关时区更改的通知)
问题描述
我的应用程序可以在设备时区更改时收到任何通知吗?我想在我的应用程序处于前台时收到通知.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 中获取有关时区更改的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 iOS 中获取有关时区更改的通知


基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01