导航子项和Tabbar控制器方向

时间:2013-04-08 07:14:23

标签: objective-c uinavigationcontroller uitabbarcontroller orientation push

您好我有一个应用程序,其中包含以下控制器层次结构:

  1. 的UITabBarController
  2. 使用Table ViewController的导航控制器
  3. UIView控制器
  4. 情况如下。我希望所有的导航控制器都是纵向的,只有最后一个控制器应该是横向的。为了正确的风景左。

    现在的问题是: 当我按下新控制器(最后一个)时,我希望方向为横向左侧。 我已经超越了方法shouldAutorotate和shouldAutorotateToInterfaceOrientation。我还用面具LandscapeLeft?

    覆盖了SupportedInterfaceOrientations方法

    我错过了什么吗?

    我还在导航和标签栏控制器中实现了所有旋转方法。 在标签栏中:

    -(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;
    }
    

    并在导航控制器中:

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

    非常感谢任何帮助。

    这些是最后一个控制器中的方法

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    }
    
    -(BOOL)shouldAutorotate
    {
        return YES;
    }
    
    -(NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscapeLeft;
    }
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
        return UIInterfaceOrientationLandscapeLeft;
    }
    

1 个答案:

答案 0 :(得分:1)

还有一种方法可能需要覆盖

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeLeft;
}

系统在全屏显示视图控制器时调用此方法。当视图控制器支持两个或更多方向时,您可以实现此方法,但内容在其中一个方向中最佳显示。

相关问题