Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The UITabBarController, sadly, doesn't handle view controllers with different rotation requirements very well. The best way to handle this is to subclass UITabBarController and in shouldAutorotate, simply pass the request on to the view controller that is on screen. The code would look like this:</p> <pre><code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Let's grab an array of all of the child view controllers of this tab bar controller NSArray *childVCArray = self.viewControllers; // We know that at 5 or more tabs, we get a "More" tab for free, which contains, assumingly, // a more navigation controller if (self.selectedIndex &lt;= 3) { UINavigationController *navController = [childVCArray objectAtIndex:self.selectedIndex]; // We're in one of the first four tabs, which we know have a top view controller of UIViewController UIViewController *viewController = navController.topViewController; return [viewController shouldAutorotateToInterfaceOrientation:interfaceOrientation]; } else { // This will give us a More Navigation Controller UIViewController *viewController = [childVCArray objectAtIndex:self.selectedIndex]; return [viewController shouldAutorotateToInterfaceOrientation:interfaceOrientation]; } return NO; } </code></pre> <p>This assumes that you're 5+ view controllers use the tab bar's more navigation controller and are not themselves in their own uinavigationcontroller. If they were, altering this code to fit would be trivial.</p> <p>I have posted this subclass up on my github, so you can copy this method or just grab the .h/.m files from <a href="https://github.com/jmstone617/PickyTabBarController" rel="nofollow">here</a></p>
    singulars
    1. This table or related slice is empty.
    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.
    2. 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