I have a UITabBarController in my MainWindow.xib.
Each tab contains a UINavigationController which has a UITableViewController.
When I press a button in the UITableViewController I want to push a view controller onto the navigation stack in horizontal orientation.
I have over-ridden the following in the UITableViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return YES;
}
but the pushed view controller does not appear in horizontal orientation (in the XIB it is defined as landscape).
How can I push it in horizontal orientation?
Autorotation for
UITabBarControllerandUINavigationControllerhas got some constraints:for UITabBarController, autorotation will work only if all of the controllers in the tab bar support autorotation;
for UINavigationController, autorotation will work only if the rootViewController in the UINavigationController supports it.
Once you have ensured that this conditions are met, then you can try and push your UITableViewController having defined its shouldAutorotateToInterfaceOrientation like this:
EDIT:
All of your UIViewControllers should have this definition for
shouldAutorotateToInterfaceOrientation:except the one you want to force to landscape, which should have the definition given above.
Also have a look at the last post in this thread to correctly implement shouldAutorotateToInterfaceOrientation for UITabBarController.