Autorotation


#1

When I tried to type the method “shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)x” XCODE told me that method had been deprecated and that I should use “supportedInterfaceOrientations” and “preferredInterfaceOrientationForPresentation.” Looking up autorotation in the documentation, it said to use the deprecated method. Seems the documentation is not up to date with XCODE. Can anyone help me figure out how to use the two new methods? I haven’t a clue.
Thanks,
Ashley


#2

Looks like you are using a newer version of Xcode.
See the UIViewController Class Reference in iOS Developer Library at:

https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926

You should also read the Companion guides:
View Controller Programming Guide for iOS
View Controller Catalog for iOS


#3

The link you provided supported my statement that the book’s code was out of date. The latest version of XCode, which I have, says the book’s method has been deprecated in iOS 6 and the two new methods I mentioned in my first post were the way to go. Can anyone help me figure out how to use these two new methods?
Thanks,
Ashley


#4

How to use them is explained in the section Supporting Multiple Interface Orientations in the View Controller Programming Guide for iOS:

https://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/RespondingtoDeviceOrientationChanges/RespondingtoDeviceOrientationChanges.html#//apple_ref/doc/uid/TP40007457-CH7-SW1

#5

Hello,

Here’s the code I used in HeavyViewController.m:

[code]-(BOOL)shouldAutorotate{
return YES;
}

-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAllButUpsideDown;
}[/code]
As far as I understand it, the first method specifies whether or not the view should rotate at all, and the second method specifies the allowable interface orientations.


#6

Thanks guys! Your help got me through the issue.