I have a UITabBarController
controlling multiple UIViewControllers
which display different UIViews
.
ALL BUT ONE of the views should display ONLY IN PORTRAIT MODE, without being able to rotate, while ONLY ONE VIEW should display in LANDSCAPE MODE ONLY, without being able to rotate.
It seems trivial, but I am unable to achieve this... Either all views are in portrait mode or all of them are in landscape mode. They either all rotate or none of them does.
Below is the code for the Landscape view, but the instructions are completely neglected by the compiler and the view rotates to portrait mode when the device is rotated.
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
-(BOOL) shouldAutorotate
{
return NO;
}
The only way to stop the autorotation is by ticking a box in Device Orientation
in IB, but then the setting is applied to ALL the views and none of them rotates..
I've read that recently it is no longer possible to apply individual settings to each view, which seems to be absurd.
Is there any workaround?
Edited with more info: @ManWithBeard, I cannot figure out how to adapt your code to mine.. My UITabBarController controls different UIViewControllers, defined in their headers as follows:
@interface Portrait_ViewController : UIViewController
@interface LandscapeViewController : UIViewController
The AppDelegate takes to the first view controller with
[self.tabBarController setSelectedViewController: Portrait_ViewController]
and then from any ViewContoller, I move to the desired one with
[self.tabBarController setSelectedIndex:index]
I don’t understand how to apply UITabBarController
to the UIViewControllers with @interface ChildOrientationTabBarController : UITabBarController
as you have suggested.