代码之家  ›  专栏  ›  技术社区  ›  fannheyward

全屏模式视图无法在iPad iOS 6上旋转

  •  0
  • fannheyward  · 技术社区  · 13 年前

    代码:

    HDComposeViewController *vc = [[HDComposeViewController alloc] init];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
    nav.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentModalViewController:nav animated:YES];
    

    设备旋转时,当前模式视图无法旋转。如果我改变 modalPresentationStyle 到 UIModalPresentationFormSheet ,它有效!!!

    HDComposeViewController已实现轮换代理:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return YES;
    }
    
    - (BOOL)shouldAutorotate
    {
        return YES;
    }
    

    有什么问题吗?谢谢

    2 回复  |  直到 13 年前
        1
  •  0
  •   kaar3k    13 年前

    您需要为导航控制器添加一个类别,以便在ios 6中旋转。

    @interface UINavigationController (RotationAll)
        -(NSUInteger)supportedInterfaceOrientations;
    @end
    
    @implementation UINavigationController (RotationAll)
    -(NSUInteger)supportedInterfaceOrientations {
        return UIInterfaceOrientationMaskPortrait;
    }
    @end
    
        2
  •  0
  •   user2164710 user2164710    13 年前
    -(NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskAll;
        }
    
    -(BOOL)shouldAutorotate
    {
        return YES;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationPortrait;
    }
    
    推荐文章