ios - 作为框架开发人员,为什么我不能强制 iPad 上的 UIViewController 方向为纵向?

标签 ios cocoa-touch ipad uiinterfaceorientation

我们的客户指定设备唯一可用的方向应该是纵向模式。在应用程序中设置它很容易,但我正在开发一个框架。这就是为什么我将以下代码添加到我们框架中可用的每个 ViewController 的原因:

   override open var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return UIInterfaceOrientationMask.portrait
    }

    override open var shouldAutorotate: Bool {
        return false
    }

    override open var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
        return UIApplication.shared.statusBarOrientation
    }

问题是它不适用于 iPad... 它适用于所有 iphone,但不适用于 iPad。也许有人知道如何通过特定的实现所需的行为 View Controller ?

最佳答案

问题是 iPad 应用程序的默认项目级设置是需要全屏(在应用程序目标 -> 常规中)被选中。这意味着您的代码甚至没有被查阅。仅当使用您的框架的每个应用程序都选中该复选框时,您正在做的事情才会起作用。

关于ios - 作为框架开发人员,为什么我不能强制 iPad 上的 UIViewController 方向为纵向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54773939/

相关文章:

iphone - 在委托(delegate)方法中访问单元格的属性

ios - Web 服务值未出现在标签中

cocoa-touch - iOS App 的非英语默认语言?

iphone - 请问NSMutableDictionary的objectForKey : method return copy or the object itself?

ios - 通过越狱加载的应用程序的文档文件夹的位置

html - 如何在我的网站上阻止 iPad 多任务处理手势

ios - CollectionView 单元格未显示

ios - 具有动态 header 的 UICollectionViewController(如 Reddit 应用程序)

ios - 以编程方式创建的 UISplitViewController 没有滑动手势来显示/隐藏 master

iphone - 核心数据数据访问模式?