iphone - 仅当手动更改时才检测设备时间更改

标签 iphone ios objective-c datetime

问题:我知道用于检测手动时间更改的方法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. The delegate can implement this method to adjust any object of the application that displays time or is sensitive to time changes.

因此,它不仅可以检测手动时间更改,还可以检测午夜的到来。在我的应用程序中,这会产生一个问题,因为用户将看到一个警报框:

You have change the time. Please revert back to actual time.

即使他在午夜后恢复应用程序(或者他可能最小化应用程序并进入休眠状态。第二天他醒来,恢复应用程序并令人惊讶地收到时间更改通知)。

问题: 如何仅在手动时间更改时显示警报,而不是在午夜到来时显示警报?

最佳答案

只需使用NSSystemClockDidChangeNotification Apple doc link

关于iphone - 仅当手动更改时才检测设备时间更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17437725/

相关文章:

ios - 'UITableView' 没有可见的@interface 声明选择器 'setShowsUserLocation:'

ios - UINavigationController 与 ViewController 内容重叠

ios - 如何清除mkmapview的缓存

ios - 我可以使用UIWebView(iOS)自动登录youtube吗?

ios - WKWebView 在模拟器上保持空白(允许任意加载)

ios - 为什么我的 UILabel 没有被设置?

ios - 子类化 UICollectionViewCell 导致永远不会被选择

iphone - 在 iOS 6 中打开 Google map 应用

iphone - 我可以在 Monotouch 中分配多少内存?

ios - 什么是 iPhone 7(new) 屏幕分辨率、像素和尺寸?