【发布时间】:2012-11-29 09:06:43
【问题描述】:
我目前正在做一个项目,我们有一个带有 4 个标签的标签栏控制器,每个标签都有一个导航控制器。在这些导航控制器中的每一个上,都推送了多个视图控制器。
我在这里和其他地方看了很多帖子,我们目前做了以下工作:
子类UITabbarcontroller
- (BOOL)shouldAutorotate
{
return [[[self.viewControllers objectAtIndex:self.selectedIndex]topViewController] shouldAutorotate];
}
- (NSUInteger) supportedInterfaceOrientations
{
return [[[self.viewControllers objectAtIndex:self.selectedIndex]topViewController]supportedInterfaceOrientations];
}
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return [[[self.viewControllers objectAtIndex:self.selectedIndex]topViewController] shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
}
如果我们在每个视图控制器中指定以下内容,则可以正常工作:
- (NSUInteger) supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return YES;
}
这将按预期将其锁定为纵向。
但现在真正的问题出现了! 如果我们在其中一个选项卡上的视图控制器中指定它应该旋转到横向,它可以正常工作,但是当我们更改选项卡时它仍然是横向的,这不是我们想要的!
总而言之,有没有人找到解决方案来解决如何将几乎所有视图锁定到给定方向(期望一个),并且可以在您指定的方向(此处为纵向)中更改选项卡?
我也阅读了这篇文章iOS 6 UITabBarController supported orientation with current UINavigation controller,但正如一条评论中提到的那样,“这几乎对我有用。问题是,当我将标签切换到仅纵向视图时,如果我已经处于横向状态,它仍然处于横向状态。旋转纵向修复它,它不会旋转回横向,但我仍然需要它在第一次加载时是纵向的”,这在这里几乎是一样的..
【问题讨论】:
标签: ios uinavigationcontroller ios6 uitabbarcontroller