Supporting all orientation in morenavigationcontroller and children viewcontroller inside tabbarcontroller iOS 6

StackOverflow https://stackoverflow.com/questions/13176408

  •  25-07-2021
  •  | 
  •  

Question

I have a tabbar application. I have fixed orientation for tabs by setting tab bar controller to window root view controller and then overriding behavior of navigationcontroller and tabbacontroller by sub classing (Although not recommend). Now orientation works in all tabs except more navigation controller and its children view contrllers. I know the problem is device rotation notification is not being passed to children view controllers inside morenavigationcontroller in Tab bar controller. Also, more navigationcontroller is readonly property.

My problem is I want to support all orientation in morenavigationcontroller and in children view controllers also. Now shoulautorotate inside children view controllers of morenavigation controller is not being called.

Was it helpful?

Solution

After iOS 6, Apple changed how orientation works in apps. Please look at following thread. It is of great help

Tabbar controller with navigationcontrollers orientation ios 6

Or you can make your custom tabbarcontroller and implement following methods

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // You do not need this method if you are not supporting earlier iOS Versions
    return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

-(NSUInteger)supportedInterfaceOrientations
{
    return [self.selectedViewController supportedInterfaceOrientations];
}

-(BOOL)shouldAutorotate
{
    return YES;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top