tabBarController and navigationControllers in landscape mode, episode II

前端 未结 7 1960
轻奢々
轻奢々 2020-12-08 09:11

I have a UITabBarController, and each tab handles a different UIViewController that pushes on the stack new controllers as needed. In two of these tabs I need, when a specif

相关标签:
7条回答
  • 2020-12-08 09:38

    From what I have seen here and elsewhere I have stitched together a solution that uses the method shouldAutorotate since the old shouldAutorotateToInterfaceOrientation has been deprecated.

    I have placed it inside a category to UITabBarController. I so hope this is admissible!

    // call to method shouldAutorotate replaces call to method shouldAutorotateToInterfaceOrientation (deprecated)
    -(BOOL)shouldAutorotate
    { // check whether selected view controller should autorotate    
      UIViewController *controller = self.selectedViewController;
      if ([controller isKindOfClass:[UINavigationController class]])
        { // in case it is a navigation controller: get visible view of that
          controller = [(UINavigationController *)controller visibleViewController];
        }
      return [controller shouldAutorotate];
    }
    
    0 讨论(0)
提交回复
热议问题