快速问题:
我有一个带有 2 个导航 Controller 的 UITabBarController [让它们称为左 Controller 和右 Controller ]
在默认选择的左 Controller 上,我可以推送一个新的 View Controller 来检测界面方向。
在右侧 Controller 上,我可以推送相同的 View Controller ,但它不会检测界面方向,或者就此而言,它甚至根本不会进入 shouldAutoRotateInterface 方法 T___T
哈哈!!
如果有任何相关性,我推送的 View Controller 将使用 hidesBottomBarWhenPushed 属性。
最佳答案
这很可能是您的问题:
Tab bar controllers support a portrait orientation by default and do not rotate to a landscape orientation unless all of the root view controllers support such an orientation. When a device orientation change occurs, the tab bar controller queries its array of view controllers. If any one of them does not support the orientation, the tab bar controller does not change its orientation.
解决方案是在通向您的 View 的每个 View Controller 上重写以下方法:
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
return YES;
}
例如,不要使用 IB 中默认的 UITabBarController
,而是将其替换为您自己的仅包含上述方法的子类。
关于iphone - 界面方向和 UITabBarController 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3425692/