I am trying to follow a previous question in allowing a navigation controller view controllers in having different orientation rules. Previous Question
So for example, I have two view controllers the first is a Welcome the second Home. I would like the first view controller to only be Potrait and the second (Home) to allow both Port/Landscape.
I am not sure I quite understand in full how to complete this. Once I do, I intend to create a seperate project explaining how to do this and add to Github/share on the question for future reference.
In this particular project I am using a side view controller github project. PPRevealSideViewController.
My app Delegate is the following:
// Then we setup the reveal side view controller with the root view controller as the navigation controller
welcomeViewController = [[MESWelcomeViewController alloc] init];
UINavigationController *navController = [[MESNavViewControllerSubClass alloc] initWithRootViewController:welcomeViewController];
self.revealSideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:navController];
[self.revealSideViewController setDirectionsToShowBounce:PPRevealSideDirectionNone];
[self.revealSideViewController setPanInteractionsWhenClosed:PPRevealSideInteractionContentView | PPRevealSideInteractionNavigationBar];
//self.window.rootViewController = welcomeViewController;
self.window.rootViewController = self.revealSideViewController;
[self.window makeKeyAndVisible];
From the above you can see I have subclassed the Navigation Controller as MESNavViewController. This is my head for this file:
@interface MESNavViewControllerSubClass : UINavigationController {
BOOL setLandscapeOK;
}
Imp file for MESNavViewController:
-(void)viewDidLoad {
NSLog(@"subclass called");
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
if (self->setLandscapeOK) {
// for iPhone, you could also return UIInterfaceOrientationMaskAllButUpsideDown
return UIInterfaceOrientationMaskAll;
}
return UIInterfaceOrientationMaskPortrait;
}
In my first (Welcome) View controller I have the following:
-(void)viewWillAppear {
BOOL setLandscapeOK = NO;
}
- (NSInteger)supportedInterfaceOrientations {
// Restriction for the welcome page to only allow potrait orientation
return UIInterfaceOrientationMaskPortrait;
}
In my second (Home) View controller I have only the following:
-(void)viewWillAppear {
BOOL setLandscapeOK = YES;
}
What I am seeing is both view controllers within the nav allow either orientation. I am not sure I quite understand it correctly. Hopefully I have provided enough information.
EDIT ----- I have updated the PPRevealSidePanel sub class which is the very top level controller. This then holds the nav controller, which in turn holds the view controller. The orientation should be decided by the view controller displayed.
PPRevealSidePanel Sub class -
Secondly I receive an error trying to update the setter setLandscapeOK for this sub class, on the actual view controller.
Login View controller -