Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As far as I can tell, this problem arises because the UITabBarController and UINavigationController are returning their own default values for -(BOOL)shouldAutorotate and -(NSUInteger)supportedInterfaceOrientations.</p> <p>One solution is to extend both of those classes via categories (or just subclass), in order to return the appropriate values from your own implementations of these methods in your view controller. This is what worked for me (you can just drop this into your App Delegate):</p> <pre><code>@implementation UITabBarController(AutorotationFromSelectedView) - (BOOL)shouldAutorotate { if (self.selectedViewController) { return [self.selectedViewController shouldAutorotate]; } else { return YES; } } - (NSUInteger)supportedInterfaceOrientations { if (self.selectedViewController) { return [self.selectedViewController supportedInterfaceOrientations]; } else { return UIInterfaceOrientationMaskAllButUpsideDown; } } @end @implementation UINavigationController(AutorotationFromVisibleView) - (BOOL)shouldAutorotate { if (self.visibleViewController) { return [self.visibleViewController shouldAutorotate]; } else { return YES; } } - (NSUInteger)supportedInterfaceOrientations { if (self.visibleViewController) { return [self.visibleViewController supportedInterfaceOrientations]; } else { return UIInterfaceOrientationMaskAllButUpsideDown; } } @end </code></pre> <p>By default, all your view controllers will continue to autorotate. In the two View Controllers that should only support portrait mode, implement the following:</p> <pre><code>-(BOOL)shouldAutorotate { return NO; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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