UIViewController Interface Orientation is always the same value

No matter how I rotate the iPad, viewcontroller.interfaceOrientation always returns 1. Does anyone know why this is?

+3
source share
2 answers

It completely depends on where your viewcontroller sits in the heirarchy view.

A UIWindow should have only one view manager (usually the rootViewController) associated with it, and it is a view manager that responds to rotation. If the rootViewController has multiple child view controllers, you will need to detect a rotation in the root controller and pass it to the appropriate view manager

- . , . , .

+1

, , iOS 6.0.

:

- (UIInterfaceOrientation)interfaceOrientation;
{
    UIViewController *rootViewController = self.view.window.rootViewController;
    if (rootViewController) {
        return rootViewController.interfaceOrientation;
    }
    return [super interfaceOrientation];
}
0

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


All Articles