问题:我知道用于检测手动时间更改的方法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/