In iOS 5, the shouldAutorotateToInterfaceOrientation: method was used to specify which orientations an App supported. This method was deprecated in iOS 6.
When a method is deprecated, it typically means that you should avoid using it because it has been superseded. In this case, shouldAutoRotateToInterfaceOrientation: is never called on a device that is running iOS 6, although it is still called under iOS 5.
So, if you want your App to work on devices running iOS 5 (you usually do), then you should still implement the shouldAutoRotateToInterfaceOrientation: method.
In iOS 6, Apple has replaced this method with two other methods:
If you don’t implement these methods, your App will support the following orientations by default in iOS 6:
- iPhone – All orientations exception portrait-upside down
- iPad – All orientations
If you want to limit the orientations supported by your App in iOS 6, you need to implement the new supportedInterfaceOrientations method to indicate the orientations your App supports. This method returns a bit mask specifying which orientations are supported. For example, the following code indicates the App supports portrait, and landscape-left orientations:
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft;
In this example, the vertical line indicates the Objective-C bitwise inclusive OR operator.
The shouldAutorotate method is intended to temporarily disable automatic rotation. By default, this method returns YES. You can override this method and return NO to turn off automatic rotation.
When moving your App to iOS 6, you should also check your project’s app delegate class to see if there is code in its application: didFinishLaunchingWithOptions: method like this:
If there is, it will prevent autorotation from working properly. You need to change it to:
window.rootViewController = tabBarController;
After making these changes, your App should autorotate properly in iOS6.
For more information, check out Apple’s Supporting Multiple Interface Orientations documentation.