Force Landscape ViewController in iOS 7

Here is the solution:

1) Embed the LandscapeViewController in a subclassed NavigationController and connect it from your PortraitViewController using a modal segue.

LandscapeViewController embedded into a new LandscapeNavigationController

2) Subclass UINavigationController

LandscapeNavigationController.m

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft;
}

3) Don’t forget to dismiss your modal VC (in this case from my Bar Buttom Item Action)

- (IBAction)goBack:(id)sender
{
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

Leave a Comment