mobile posts

iOS 6 Autorotate Solution

When Apple moved from iOS 5 to iOS 6, they changed the way developers must handle autorotation in their apps. 

Basically, it isn't too bad, as it should just work automatically.  But, I ended up struggling for hours without success, until I came upon this helpful website with a small, almost throw-away piece of advice:

In your AppDelegate class, in the application: didFinishLaunchingWithOptions method, you might have a line like this:

[window addSubview:viewController.view];

This is especially likely if you are updating an app from iOS 5 or below.

This line will actually prevent autorotation from working in iOS 6!  Change it to this:

window.rootViewController = tabBarController;
// (or set to whatever navController you might be using)

So, to reiterate, I spent hours and hours pulling my hair out, when it turns out I needed to change one line of code, in an area of the app which seems to have nothing to do with autorotation at all.  Thanks Apple!

Syndicate content