iphone - 界面方向和 UITabBarController 的问题

标签 iphone uitabbarcontroller uiinterfaceorientation

快速问题:

我有一个带有 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/

相关文章:

iphone - 根据时区创建 NSDate 对象

ios - 在 iOS8 中使用 Swift 点击时如何隐藏/显示 tabBar

ios - 如何将屏幕从一个 TabBarItem 传递到另一个 TabBarItem?

ios - UISegmentedControl 中的两行文本

ios - 检测子类方向变化的持续时间? IOS 7

ios - 呈现的 UIViewController 拒绝横向布局

iphone - 点击 UITextField(圆形样式文本字段)时打开一个新 View

iphone - 改变高度时按比例调整 UIImageView 的宽度

ios - 为什么对 navigationController 进行覆盖 :willShowViewController:animated necessary for tab bars

iphone - AVPlayer 不播放视频文件