IPhone / iPad rotation

How to determine the start of rotation and end of rotation on these devices?

EDIT: So, after your answers, how can I determine the beginning and end of a change in orientation.

+3
source share
3 answers

The following two methods can be implemented in your UIViewController.

To detect the beginning of rotation, implement willRotateToInterfaceOrientation: duration: and to determine the final implant 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");
}
+9
source

You can use UIAccelerometer api for this

EDIT to clarify the question:

UIAccelerometer api. AccelerometerGraph, 3 . , .

0

You cannot detect a turn on any of these devices. The accelerometer detects only speed changes.

You can get a rough orientation measure from the CLLocationManager class that reports the header. This value is slowly updated, which limits its usefulness.

0
source

Source: https://habr.com/ru/post/1747339/


All Articles