Alex Stuckey
Alex Stuckey

Reputation: 1260

iOS: Universal app won't rotate, never calls willRotateToInterfaceOrientation

My (Universal iPhone/iPad) app will not rotate. In all of my viewcontrollers I return "YES" to the method shouldRotate, but my viewcontrollers' willRotateToInterfaceOrientation methods never get called.

Is this a common issue?

Upvotes: 0

Views: 1726

Answers (3)

jsd
jsd

Reputation: 7703

I just ran into this. The solution was to subclass UISplitViewController and add

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

Even though the individual view controllers were already returning YES, it didn't work until I added the split view controller subclass.

Upvotes: 0

doozMen
doozMen

Reputation: 730

In that universal app are you using a splitViewController? If so make sure all your viewControllers return Yes to should autoRotate.

I passed an array of viewControllers (actually NavigationViewControllers) to a splitViewController and my view did not rotate. This was because my left hand viewController was not implementing shouldAutorotate. I think this is because rotation on an iPad when you use a splitViewController is different then on an iPhone. When rotated it shows two viewControllers. Both have to support landscape mode i guess?

If you do not want the rotation of the one viewController to rotate do a conditional check to see if you are on an iPad in the shouldAutoRotate method.

Upvotes: 3

Wolfador
Wolfador

Reputation: 319

Are you using a tab bar? You will need to subclass your tabbar controller and return yes for should rotate.

Upvotes: 2

Related Questions