0
votes

Hello I have an app where is the following hierarchy of controllers:

  1. UITabBarCOntroller
  2. Navigation Controller with Table ViewController
  3. UIView controller

The situation is following. I would like to have all the navigation controllers in portrait and only the last controller should be in Landscape. To be correct Landscape Left.

Now the problem is: When I push the new Controller (last one) i want the orientation to be landscape left. I have overrided the methods shouldAutorotate and shouldAutorotateToInterfaceOrientation. I also overrided method supportedInterfaceOrientations with mask LandscapeLeft?

Am I missing something?

I also implement all the rotation methods in the navigation and tabbar controller. in the tabbar :

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // You do not need this method if you are not supporting earlier iOS Versions
    return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

-(NSUInteger)supportedInterfaceOrientations
{
    return [self.selectedViewController supportedInterfaceOrientations];
}

-(BOOL)shouldAutorotate
{
    return YES;
}

and in the navigation controller :

-(NSUInteger)supportedInterfaceOrientations
{
    return [self.topViewController supportedInterfaceOrientations];
}

-(BOOL)shouldAutorotate
{
    return YES;
}

Any help will be greatly appreciated.

These are the methods imlemented in the last controller

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

-(BOOL)shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeLeft;
}
1

1 Answers

1
votes

There's one more method you may want to override

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeLeft;
}

The system calls this method when presenting the view controller full screen. You implement this method when your view controller supports two or more orientations but the content appears best in one of those orientations.