我如何在这些设备上检测旋转的开始和结束?
编辑:
在您的回答之后,我如何检测方向更改的开始和结束。
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
NSLog(@"I am starting to rotate");
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
NSLog(@"I have finished rotating");
}
你可以使用UIAccelerometer API来实现这个功能。
根据问题的澄清,编辑如下:
使用UIAccelerometer API来实现这个功能。有一个很好的示例应用程序叫做AccelerometerGraph,它会在图表上显示三个加速度向量。这应该能够给你一个很好的指示,说明方向的变化会是什么样子。
这两个设备都无法检测旋转。加速度计只能检测速度的变化。
您可以从CLLocationManager类中获取方向的粗略测量值,该类报告一个航向。但是,该值更新速度较慢,其实用性受到限制。