iOS 监听用户是否手动修改了设备时间

来源:互联网 发布:紧身战斗服淘宝 编辑:程序博客网 时间:2024/04/29 13:53

可以通过注册系统通知:UIApplicationSignificantTimeChangeNotification 去实现

- (void)observeUserDeviceTimeIsChanged{    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceTimeIsChanged) name:UIApplicationSignificantTimeChangeNotification object:nil];}- (void)deviceTimeIsChanged{    NSLogI(@"用户手动调整了设备时间");}

通过这个,我们可以获取用户改了时区、时间、24/12小时制的通知,但是信息内容有限,apple的解释是:“Posted when there is a significant change in time, for example, change to a new day (midnight), carrier time update, and change to or from daylight savings time.

This notification does not contain a userInfo dictionary.”

即获取到的通知内容不携带userInfo 字典。

0 0
原创粉丝点击