I have a UITabBarController that I want to show in portrait orientation and a UIViewController to show when in landscape orientation.
I add both controller's view to the window.
I have the shouldAutorotateToInterfaceOrientation method like this for each controller.
This works great but the status bar always stays in landscape mode after the first rotation to landscape. When returning to portrait the UITabBarController will display properly but the status bar will not be returned to the right position.
Thanks for the help! If there is a better way to do this please let me know!
I add both controller's view to the window.
Code:
[window addSubview:viewController.view];
[window addSubview:tabBarController.view];
I have the shouldAutorotateToInterfaceOrientation method like this for each controller.
Code:
// UITabBarController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return interfaceOrientation == UIInterfaceOrientationPortrait;
}
// UIViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
return NO;
}
else if(interfaceOrientation == UIInterfaceOrientationPortrait)
{
[window bringSubviewToFront:[tabBarController view]];
return NO;
}
// landscape
[window bringSubviewToFront:[self view]];
return YES;
}
This works great but the status bar always stays in landscape mode after the first rotation to landscape. When returning to portrait the UITabBarController will display properly but the status bar will not be returned to the right position.
Thanks for the help! If there is a better way to do this please let me know!