您的位置:首页 > 移动开发 > IOS开发

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

2016-01-12 14:28 543 查看
可以通过注册系统通知: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 字典。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: