0
votes

I am developing an application that has several views and a root view controller. It's based on UINavigationController using pushViewController: In didFinishLaunchingWithOptions:

BIDLoginController *loginController = [[BIDLoginController alloc] initWithNibName:@"Login" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:loginController];
[self.window setRootViewController:self.navController];

In loginController:

BIDMainPageController *mainPageController = [[BIDMainPageController alloc] initWithNibName:@"MainPage" bundle:nil];
[self.navigationController pushViewController:mainPageController animated:YES];

but the view controllers are subclasses of UIViewController, not UINavigationController. Now I want some of the views to support orientation(portrait and landscape) and some of them only support portrait. I have tried the following:

- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

It doesn't work. shouldAutorotate: method never been called. I have tried UINavigationControllerDelegate with no result either. When I change these view controllers' super class from UIViewController to UINavigationController, the view doesn't show up, only a navigation bar is shown. Can anyone help with this?

1
possible duplicate of Unsupport Orientation in iOS6matt

1 Answers

0
votes

You can't do what you are describing. iOS 6 doesn't support forcing different child view controllers of a UINavigationController to rotate. They can respond differently to device rotation, but they cannot be forced to rotate.