I have a Tab Bar app with 5 tabs. I'm using the app delegate to allow landscape orientation in only one tab, and that works fine. The only problem is that after I rotate that view controller, all the other view controllers in the other 4 tabs will all rotate as well.
In my app delegate:
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
if (self.shouldRotate)
return UIInterfaceOrientationMaskAllButUpsideDown;
else
return UIInterfaceOrientationMaskPortrait;
}
In my 4 portrait view controllers:
- (void)viewDidLoad{
[super viewDidLoad];
// Do any additional setup after loading the view.
AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate setShouldRotate:NO];
}
In my 1 landscape view controller:
- (void)viewDidLoad {
[super viewDidLoad];
[self loadWebViewRequest];
AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate setShouldRotate:YES];
}
Why are my 4 portrait view controllers rotating after the landscape vc rotates?
All the other answers I've seen here don't address how to correctly implement this using a Tab Bar application.