I'm developing an iPhone application that has several nibs, and should be landscape only.
The application is set to start in landscape mode via its Info.plist file.
I have two view controllers:
FirstViewController
and SecondViewController
.
For each of these I have a nib file, where the view is in landscape. Both view controllers are added to my MainView
nib as outlets, and their views are lazily initialized.
When the application loads, the first view displays in landscape, as expected. However, when I switch to the second view, the device (or simulator) remains in landscape, but the view is rotated, as if the device were in portrait mode, braking my interface.
In both UIViewController
classes I have the following code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
and to switch views, in my app delegate I'm doing:
[viewController.view removeFromSuperview];
[window addSubview:secondViewController.view];
where viewController
and secondViewController
are the two outlets where the view controllers are connected.
This is how the second view looks in IB:
and this is how it looks in the simulator:
Why is that the second view is displaying in landscape but with the interface rotated?
I wouldn't like to deal with transform properties, since that seems overkill.