Auto-rotation broken in iOS 6 with XCode 4.5?

This is another one of those delightful issues where your code starts behaving differently when compiled in XCode 4.5 (while iOS itself is backwards compatible, the SDK is most certainly not. SDK methods can completely change functionality when compiled & run on newer versions).

When I ran up my XCode 4.4.1, iOS 4 & 5 project in XCode 4.5 + iOS 6, I noticed that autorotate had completely stopped. The secret was I needed to set the window’s rootViewController. This is a “new” method of UIWindow (my project dates from iOS 2.0!). Previously you would [window addSubview:viewController.view], but it seems now you just set the rootViewController directly. If you need to support pre-iOS 4 then you could still do the latter.

	self.window.rootViewController = viewController;  // add this line
	[window addSubview:viewController.view];   // optional: remove this line

Thanks to this answer on SO.

If you’re still having issues, I check your UISupportedInterfaceOrientations in the plist, you should have 1 for iPhone (that one), and on for iPad UISupportedInterfaceOrientations~ipad (these are the ‘raw’ keys).

NB. I’m referring to the case of when auto-rotate broke on updating to iOS 6. If your autorotate simply isn’t working, then you may have a more rudimentary AutoRotate issue, for which StackOverflow is your friend.

Leave a Reply

Your email address will not be published. Required fields are marked *