【发布时间】:2014-04-17 15:58:01
【问题描述】:
我想在 iOS 6 和 7 中支持自动旋转。在我的项目中,我有一个带有 4 个 ViewControllers 的 UITabBar。其中只有一个 ViewController 应该支持纵向和横向的自动旋转。其他视图应该只支持 Portrait 样式。
我希望你知道如何实现这个功能。 shouldautorotatetointerfaceorientation 在 iOS 7 中不起作用 :(
我添加了一个 UITabBarConntroller 来控制自动旋转
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
if (self.selectedIndex == 1)
return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationPortrait);
else
return UIInterfaceOrientationMaskPortrait;
}
当索引为 1 的视图确实消失时,也许有办法更改方向手册??
希望你有解决办法!
【问题讨论】:
-
您可以在每个视图控制器中定义这些方法,然后再次将
return self.selectedViewController.shouldAutorotate;和self.selectedViewController.supportedInterfaceOrientations;放在Tab Bar Controller 类中。这将从活动视图控制器中检索shouldAutorotate和supportedInterfaceOrientations值并将它们用于标签栏控制器。
标签: ios objective-c uiinterfaceorientation