开发者

Orientation problem with tabbarcontroller + navigation controller [duplicate]

开发者 https://www.devze.com 2023-03-02 17:43 出处:网络
This question already has answers here: Selective Autorotation within a UINavigationController and UITabBarController
This question already has answers here: Selective Autorotation within a UINavigationController and UITabBarController 开发者_运维问答 (3 answers) Closed 2 years ago.

I have one TabBarController that has Two tabs. Each tab has one NavigationController in it. Now if the first tab is selected and I rotate the app then shouldAutorotateToInterfaceOrientation: gets called of rootViewController of first tab nav controller and thats right but when I select the second tab and then I rotate the device then still the shouldAutorotateToInterfaceOrientation: method of first tab gets called.

I want to layout different tab differently. Any help would be appreciated. Thanks


The tab bar controller can only change to another orientation if the root view controller of each tab supports that orientation. Which makes sense, otherwise a user would somehow switch orientation when she selected another tab.


Override this method and call this method in view will appear.

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
 {
     if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
  {

  }
 }
0

精彩评论

暂无评论...
验证码 换一张
取 消