Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you plan to enable or disable rotation for all view controllers you don't need to subclass UINavigationController. Instead use:</p> <pre><code> -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window </code></pre> <p>in your AppDelegate.</p> <p>If you plan to support all orientations in your app but different orientations on PARENT View Controllers (UINavigationController stack for example) you should use</p> <pre><code> -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window </code></pre> <p>in combination with the following methods in your Parent View Controller.</p> <pre><code> - (BOOL)shouldAutorotate </code></pre> <p>and</p> <pre><code>- (NSUInteger)supportedInterfaceOrientations </code></pre> <p>But if you plan to have different orientation settings in different CHILDREN ViewControllers in the same navigation stack (like me) you need to check the current ViewController in the navigation stack.</p> <p>I've created the following in my UINavigationController subclass:</p> <pre><code> - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { int interfaceOrientation = 0; if (self.viewControllers.count &gt; 0) { id viewController; DLog(@"%@", self.viewControllers); for (viewController in self.viewControllers) { if ([viewController isKindOfClass:([InitialUseViewController class])]) { interfaceOrientation = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; } else if ([viewController isKindOfClass:([MainViewController class])]) { interfaceOrientation = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; } else { interfaceOrientation = UIInterfaceOrientationMaskAllButUpsideDown; } } } return interfaceOrientation; } </code></pre> <p>Since you cannot control anymore from children ViewControllers the rotation settings of presented view controller you must somehow intercept what view controller is currently in the navigation stack. So that's what I did :). Hope that helps !</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload