我想记录设备运动时间戳属性。
设备运动位于 CMMotionManager.devicemotion.timestamp 类中
有任何想法吗。
这是我提出的解决方案,因为日期是根据 Apple 文档确定的:
时间戳是自电话启动以来的时间量(以秒为单位)。
我首先保存第一个测量的起点(如果我的 NSDate 为零)。
[self.motionManager startGyroUpdatesToQueue:self.queue withHandler:^(CMGyroData *gyroData, NSError *error) {
if (self.originDate == nil) {
self.originDate = [NSDate dateWithTimeIntervalSinceNow:-gyroData.timestamp];
}
}];
然后我可以在需要真实日期时显示,如下所示:
[NSDate dateWithTimeInterval:mygyroData.timestamp sinceDate:self.originDate]
如果您需要重新启动某些测量,请不要忘记将 originDate 重置为 nil。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)