Using Navigation Controller in TabBar Controller Iphone 6+ IOS 8.3

150 views Asked by At

I am recently facing an issue in my app on iphone 6+ IOS8.3. The issue is i am using uitabbarController in my app and each tab of tab bar controller contains a uinavigationController.

Now when i select the 6th/7th tab by going into More tab and then rotate the screen then black screen appears.

To test the scenario i made an saperate applictaion and make the same structure, i.e made 9 tabs and each tab contain navigation controller. All this is done on storyboard and no code was written.

Then i run the app and select the 6th tab and rotate the screen, the black screen appears. and when i rotate back to portrait then everything become fine again.

I am attaching the screen shots for further explanation.

i Make an dummy app with 9 tabs, each tab  has UinavigationController.Tap on More and see the remaining tabs.

select the 6th tab (second tab in More Tab )

Rotate the device it will show black screen.

So anyone able to tell why it turns into black screen? I am doing it wrong ? or That is a bug of IOS8.3 or something else?

1

There are 1 answers

0
Peter Grundner On

I ran into the same issue today and since this question has not been answered yet, I'd like to present my simple solution.

  1. In your UITabbarController subclass, subscribe to the rotation events:

    [[NSNotificationCenter defaultCenter] addObserver:self                                          //Add yourself as an observer
                                         selector:@selector(orientationChanged:)
                                             name:UIDeviceOrientationDidChangeNotification
                                           object:[UIDevice currentDevice]];
    
  2. Add the following code to the rotation observer method:

    - (void) orientationChanged:(NSNotification *)notification {
        if (IS_IPHONE_6P) { // some magic to figure out if we're on iphone 6 plus
            self.customizableViewControllers = @[]; // we don't want an edit button to appear
            if (self.selectedIndex == 5 || self.selectedIndex == 6) { // the effect only happens to view controllers at index 5 and 6.
                [self.moreNavigationController popToRootViewControllerAnimated:NO]; // pop the view controller from the moreNavigationViewController
                self.selectedViewController = self.viewControllers[self.selectedIndex]; // set the selected view controller to be visible again.
            }
        } 
    }