ShouldAutorotateToInterfaceOrientation & UINavigationController

I am trying to implement automatic rotation in my application, which is basically a UINavigationController with a lot of UIViewControllers that click on it.

I copied this to my first UIViewController (which falls into the UINavigationController):

- (BOOL) shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation) interfaceOrientation {
 return YES;
}

Everything worked fine ... However, if I paste this code into the second UIViewController (the first clicks from above after clicking one button) - autorotation will not work. shouldAutorotateToInterfaceOrientation is called when the UIViewController is first initialized, but after it is visible and I rotate the device, nothing happens.

Thus, the result: the first view is well rotated - portrait / landscape ... but after I press the button and go into the second view, I remain in this portrait or landscape, no matter what is active.

I tried subclassing the UINavigationController and set toAutorotateToInterfaceOrientation there, but that also doesn't work.

What am I doing wrong?

+3
source share
2 answers

API , . setOrientation, API , , . , ( , 4.0 - ). , , .

+1

0

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


All Articles