如何在tabbar中允许vc的子vc自动旋转?

时间:2012-11-14 15:56:27

标签: ios autorotate

我有一个标签栏视图控制器,其中包含一些导航控制器,每个控制器都有一个根视图控制器。一切都只能以人像呈现。一切都很好。其中一个子视图控制器使用它的导航vc推送另一个视图控制器,并且我希望允许旋转以进行横向显示。

Tabbar vc
   nav vc/vc1
   nav vc/vc2
   nav vc/vc3
      pushes new vc4   <- ONLY this one should autorotate. Further more, if you're in landscape mode in this vc and hit 'back', it goes back in portrait.

app'line'执行此操作 - 实际的'chat'窗口可以自动旋转。

请给我代码! ;)我希望它不需要搞乱转换...

2 个答案:

答案 0 :(得分:1)

要在UITabBarController应用程序上支持自动旋转,您需要在tabBarController上对视图控制器旋转调用进行子类化,并询问当前显示的视图控制器是否支持新方向。在您的具体情况下,将询问vc4是否支持方向更改,因此标签栏可以在被询问时旋转。

看一下这个问题:tabBarController and navigationControllers in landscape mode, episode II

答案 1 :(得分:0)

@Colin在你的Tabbar视图控制器中,将其限制为像

一样的肖像
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

并在新的uiviewcontroller(vc4)中,将其限制为横向。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight) );
}

希望它有所帮助。

相关问题