我想记录设备运动时间戳属性。
设备运动位于 CMMotionManager.devicemotion.timestamp 类中
任何想法。
最佳答案
这是我提出的解决方案,因为日期是根据 Apple 文档得出的:
The time stamp is the amount of time in seconds since the phone booted.
我首先在第一次测量时保存 originDate (如果我的 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。
关于iphone - nslog时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6911226/