iphone - 一个 View Controller ios 的强制景观

标签 iphone ios uinavigationcontroller orientation viewcontroller

我看过几个类似问题的答案,但没有一个答案有效。我有一个应用程序,除了我拥有的一个照片查看器之外,我需要所有东西。在目标菜单的支持方向部分,我只有纵向。我如何强制我的一个观点是风景。它被从导航 Controller 插入堆栈,但我正在使用 Storyboard来控制所有这些。

最佳答案

由于答案似乎隐藏在问题的评论中,并且由于 ArunMak 的答案非常困惑,我将提供我发现的内容:

我所要做的就是将此函数添加到 View 的自定义 UIViewController 子类中:

- (NSUInteger)supportedInterfaceOrientations {
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        // iPad: Allow all orientations
        return UIInterfaceOrientationMaskAll;
    } else {
        // iPhone: Allow only landscape
        return UIInterfaceOrientationMaskLandscape;
    }
}

请注意,该项目需要允许所有方向(即:纵向、左侧横向、右侧横向 - 但决不能在 iPhone 上上下颠倒!)。

如果你想将一些或大部分 View 限制为纵向,你需要在每个 View Controller 中实现上述方法(或者为它使用一个通用的父类(super class)并从它继承所有其他的)——如果你限制设备Info.plist 中的方向仅为纵向,应用程序永远不会考虑进入横向。

关于iphone - 一个 View Controller ios 的强制景观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18409310/

相关文章:

iphone - android中的等效组件是什么,就像iphone中的uiindicator

iphone - iPhone OpenGL教程

ios - UIPageViewController 影响 UIImage 颜色?

ios - 从 subview Controller 推送 View Controller

ios - 带有 UINavigationController 的 UISplitViewController 作为详细信息 View : push controller via Storyboard segue

iphone - 旋转后UIScrollView内的UIImageView定位问题

iphone - 具有 CGContextSetInterpolationQuality 的图像质量

objective-c - NSURLConnectionDelegate 静态类包装器不调用函数调用 (ARC)

ios - 在 iOS map 上给定多个位置自动缩放和定位

ios - 如何让 "legally"淡出应用程序中的导航栏?