I am having trouble preserving my current views orientation. In the below setup, I have been able to lock the first view controller to portrait and the second viewcontroller to landscape or portrait. However, when I add a second navigation controller/rootviewcontroller to the tab controller, all of the views throughout the project will go to both landscape and portrait. This happens regardless of if I implement the same code in the first navigation controller to the second nav controller or not
I would like to be able to preserve my current view controllers orientations while adding an additional navcontroller>viewcontroller
I have the following setup in storyboard:
This is what I am trying to achieve:
Where the tabbarcontroller should support all orientations, the nav controllers support all orientations, the first view controller and table view controller supports only portrait, and the second view controller supports landscape and portrait.
And here are the methods for each of the current view controllers
TabViewController.m
-(BOOL)shouldAutorotate
{
return [[self.viewControllers lastObject] shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
NavController.m
-(BOOL)shouldAutorotate
{
return [[self.viewControllers lastObject] shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
First View Controller.m
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
Second View Controller.m
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
I would appreciate any assistance in resolving this. It has become the bane of my existence