First you should use methods for the iOS6 presented in UIViewController documentation if you are making your app for iOS6. Orientation method like shouldAutorotateToInterfaceOrientation
is deprecated in iOS6, alternate method for iOS6 is shouldAutoRotate
. You should only use the old method if your app is supporting also iOS5.
Second If you are using UINavigationcontroller
in your application and you need to have different interface orientations then navigationController could mess up the interface orientation in the application. Possible solution (worked for me) is to implement a custom UINavigationController
and override the interface orientation methods within that custom UINavigationController
class, this will make your viewControllers rotate according to the orientation you set because your controllers are pushed from the UINavigationController
. Don't forget to add those methods in your particular viewController also.
CustomNavigationController.h
@interface CustomNavigationController : UINavigationController
@end
CustomNavigationController.m
@implementation CustomNavigationController
//overriding shouldRotate method for working in navController
-(BOOL)shouldAutorotate
{
return [self.topViewController shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self.topViewController preferredInterfaceOrientationForPresentation];
}