ios - UIViewController 在 iPad 上处理方向 iOS 6.0

标签 ios ipad uiviewcontroller ios6

在我的应用程序中,我需要为我的 ViewControllers 处理不同的方向。

  1. ViewController1 必须仅支持横向。
  2. ViewController2 必须支持横向 + 纵向。

我在 Summury 项目中启用了这样的所有方向:

Summary project orientation

因此,我将此代码插入 ViewController1:

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

然后我在 ViewController2 中插入这段代码:

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

问题是 ViewController1 也在纵向旋转(它应该只支持横向)。

有什么想法吗?

非常感谢大家!

最佳答案

你的 viewController 是你的 rootViewController 吗? 如果不是,那可能是您的问题。

如果您的 rootViewController 是 UINavigationController,您应该知道它不会将这些消息转发到它的 topViewController。因此,如果这是您的情况,我建议您使用 UINavigationController 的子类,在其中覆盖这些新方法以转发到 topViewController。

关于ios - UIViewController 在 iPad 上处理方向 iOS 6.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12760457/

相关文章:

ios - 使用Facebook IOS SDK 3.1和Graph API发布带标题的图像

iphone - 附件 Action segue (UITableViewController)

iphone - Ipad/Iphone - UIView 中的图像旋转

iphone - 如何在 iOS 应用程序中实现自定义(平面图图像) map ……?

ios - 如何检查 key 对中的 key 是否可用?

ios - 如何从自定义单元格保存 UILabel 以便每次打开应用程序时它都会显示最新更改?

ios - UIPopoverController 顶部的 UIButton 消失了

ios - 将数据传递给特定的 ViewController

ios - 在所有 View Controller 上设置十六进制背景

objective-c - 当 View Controller 即将在 iOS4 中弹出时得到通知