4

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.

i.AsifNoor
  • 587
  • 5
  • 14
  • Please see similar problem and its solution at http://stackoverflow.com/questions/13622194/tabbar-controller-with-navigationcontrollers-orientation-ios-6 – Nomiii Mar 16 '14 at 12:11
  • I have solved this problem. iOS 6 and ios 7 have different method of handling orientation. Top view controller decides the orientation support for all its children. For example, if parent view controller support only portrait orientation, then child view controller can not force landscape orientation. But if you still want to achieve this, you can present the child view controller. – i.AsifNoor Apr 15 '14 at 09:02

1 Answers1

1

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;
}
Community
  • 1
  • 1
Aqib Mumtaz
  • 4,936
  • 1
  • 36
  • 33