Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIView in iOS 5 using Storyboards does not rotate content on iPad device rotation

I'm just getting started with Storyboards and iOS 5.1. The application I'm building uses a navigation controller as its root controller, and is designed to be used in landscape orientation (it's an in-house enterprise application).

I created a single view, which worked properly: The content rotates properly to stay "right side up" when the simulator changes orientation.

I then added a new view, and that one doesn't rotate at all; the content stays in portrait orientation (and thus is sideways) when the device rotates.

I've looked through the settings for the two UIViewControllers and UIViews, and can't see any difference between them. Any thoughts as to where I should look?

like image 914
Christophe Avatar asked May 31 '12 05:05

Christophe


1 Answers

First of all each UIViewController in the storyboard must have a class sosiated with it. Create a new class which inherits from UIViewController and then, in the storyboard, click on the uiviewcontroller, and at the bottom of that controller, click on the right box and in the class inspector, replace UIViewController with the name of the new class your created.

Then, make sure that in every view controller class that you create, you implement the method

-(BOOL)shouldAutoRotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

Just make this deleate method to return YES in EVERY view controller to make sure that all their views rotate in any orientation. Have you done this?

like image 104
ChrisBorg Avatar answered Nov 18 '22 16:11

ChrisBorg