Hello guys!
How can I detect the start of a rotation and the end of the rotation on these devices?
EDIT: So after your answers, how can I detect the begining and ending of the orientation change.
Hello guys!
How can I detect the start of a rotation and the end of the rotation on these devices?
EDIT: So after your answers, how can I detect the begining and ending of the orientation change.
You can use the UIAccelerometer api for this
EDIT to match question clarification:
Use the UIAccelerometer api for this. There is a good sample application called AccelerometerGraph that displays the 3 acceleration vectors on a graph. This should give you a good indication on how a shift in orientation will look like.
You can't detect rotation on either of these devices. The accelerometer only detects changes in velocity.
You can get a crude measure of orientation from the CLLocationManager class, which reports a heading. This value is slow to update, which limits its usefulness.
hi,
You can implement the following two methods in your UIViewController.
To detect a start of a rotation, implement willRotateToInterfaceOrientation:duration: and to detect the end implment didRotateFromInterfaceOrientation: .
i.e.
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
NSLog(@"I am starting to rotate");
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
NSLog(@"I have finished rotating");
}