首页 文章

解雇模态后UITabBarController不旋转

提问于
浏览
0

当用户将iPhone旋转到横向时,我试图全屏显示图像 . 为了实现这一点,我在用户从纵向旋转到横向时添加了一个全屏视图控制器的模态 . 然后,当用户旋转回肖像时,它应该关闭模态 .

所有视图都显示在TabBarViewController中,所有视图控制器都使用segue进行转换 .

注意:这是应用程序中旋转到横向的唯一视图 .

THE PROBLEM

当我关闭模态时,当手机处于纵向方向时,TabBarViewController仍然会旋转横向 . 如果我离开视图并旋转,视图将以正确的方向显示 .

Edit 带有时间,电池等的状态栏会旋转 . 屏幕上的导航栏,标签栏和视图不会旋转(以纵向方式保持横向) .

UIViewController A

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{


    if(UIInterfaceOrientationLandscapeLeft == toInterfaceOrientation ||
       UIInterfaceOrientationLandscapeRight == toInterfaceOrientation){

        // USE MODAL TO PRESENT FULLSCREEN
        UIViewController *fullViewController = [[FullScreenViewController alloc] init];
        [self.navigationController presentViewController:fullViewController animated:NO completion:nil];

    }


}

FullScreenViewController

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{

    if(toInterfaceOrientation == UIInterfaceOrientationPortrait){
        [self dismissViewControllerAnimated:true completion:nil];
    }

}

1 回答

  • 0

    我在代码中没有看到标签栏控制器(或其代理人)正在实现 supportedInterfaceOrientations (或 tabBarControllerSupportedInterfaceOrientations: )的任何迹象 . 但这才是最重要的 .

相关问题