hiding TabBar when rotating iPhone device to landscape

前端 未结 8 1591
旧时难觅i
旧时难觅i 2020-12-09 12:21

So here is what i have: A UITabBarController that handles different UIViewControllers. In one of the UIViewController i am trying to switch the view being displayed when the

相关标签:
8条回答
  • 2020-12-09 12:53

    I needed tab bar to go into full screen mode in landscape view and I tried the approach suggested above using

    transView.frame = CGRectMake(0, 0, 480, 320 );

    This turned out to be a hacky solution and posed many problems such as with hiding and re-displaying the status bar (the view would overlap with the status bar when it is re-displayed after exiting portrait view). I would not recommend this. What worked for me perfectly in the end was pushing a new view controller containing the landscape view and using delegation to reuse the functionality of the original VC.

    0 讨论(0)
  • 2020-12-09 12:54

    This approach is working for me:

    - (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    
        UIView *parentView = self.tabBarController.view;
        CGRect frame = parentView.frame;
        CGFloat windowHeight = parentView.window.frame.size.height;
    
        switch (toInterfaceOrientation) {
            case UIInterfaceOrientationLandscapeLeft:
            case UIInterfaceOrientationLandscapeRight:
                CGFloat tabBarHeight = self.tabBarController.tabBar.frame.size.height;
                frame.size.height = windowHeight + tabBarHeight;
                break;
            default:
                frame.size.height = windowHeight;
                break;
        }
    
        [UIView animateWithDuration:duration animations:^{
            parentView.frame = frame;
        }];
    }
    

    (Only tested in iOS8.)

    0 讨论(0)
提交回复
热议问题