A few simple steps in order will solve this problem for you.
First, in AppDelegate.m, check if you're adding your rootViewController as a subView. That is, instead of this,
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
do something like this
- (void)applicationDidFinishLaunching:(UIApplication *)application {
window.rootViewController = navigationController;
[window makeKeyAndVisible];
}
if you're setting a navigation controller as your root view controller.
Second, if you need to get control of the rotation methods within your navigationController's pushed viewControllers, create a category for UINavigationController like so:
#import "UINavigationController+Rotation.h"
@implementation UINavigationController (Rotation)
- (BOOL)shouldAutorotate {
BOOL result = self.topViewController.shouldAutorotate;
return result;
}
- (NSUInteger)supportedInterfaceOrientations {
return self.topViewController.supportedInterfaceOrientations;
}
@end
Now, these two orientation methods for iOS 6 upwards
-(BOOL)shouldAutorotate and
-(NSUInteger)supportedInterfaceOrientations
will get called within your classes.
This is necessary because the older rotation methods such as
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
have been deprecated from iOS 6.
So lastly, you'll need to implement these in your view controllers; something like this:
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
if you want to allow your view controller to rotate and support all orientations.
The other orientation masks are:
- UIInterfaceOrientationMaskPortrait
- UIInterfaceOrientationMaskLandscapeLeft
- UIInterfaceOrientationMaskLandscapeRight
- UIInterfaceOrientationMaskPortraitUpsideDown
- UIInterfaceOrientationMaskLandscape and
- UIInterfaceOrientationMaskAllButUpsideDown