찾다

 >  Q&A  >  본문

ios - 使用UITabBarController管理UINavigationController时,Push出第三个界面时怎么横屏?

在push出的viewcontroller里面 下面方法不会被执行

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}
怪我咯怪我咯2772일 전643

모든 응답(3)나는 대답할 것이다

  • 黄舟

    黄舟2017-04-17 13:39:49

    我之前是这么做的:
    添加UITabBarController、UINavigationController的分类

    UITabBarController (xxx)

    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return [self.selectedViewController preferredInterfaceOrientationForPresentation];
    }
    
    - (BOOL)shouldAutorotate
    {
        return [self.selectedViewController shouldAutorotate];
    }
    
    - (NSUInteger)supportedInterfaceOrientations
    {
        return [self.selectedViewController supportedInterfaceOrientations];
    }
    

    UINavigationController (xxx)

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

    회신하다
    0
  • 巴扎黑

    巴扎黑2017-04-17 13:39:49

    UINavigationController的回调是有效的,viewcontroller只有一个回调是必要的,忘了那个了。你两个都写把。其实就是你顶层的viewcontroller也要控制。

    회신하다
    0
  • ringa_lee

    ringa_lee2017-04-17 13:39:49

    请问下正确的做法是什么 我按上面做的还是没有效果?

    회신하다
    0
  • 취소회신하다