为什么我不能强迫iPad上的UIViewController方向作为框架开发人员的肖像?

问题描述 投票:2回答:1

我们的客户指定设备唯一可用的方向应为纵向模式。在应用程序中设置它很容易,但我正在开发一个框架。这就是为什么我将以下代码添加到我们框架中可用的每个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 ..也许有人知道如何使用特定的ViewControllers实现所需的行为?

ios cocoa-touch ipad uiinterfaceorientation
1个回答
1
投票

问题是iPad应用程序的默认项目级别设置是不检查需要全屏(在App Target - > General中)。这意味着您的代码甚至不会被咨询。只有在使用您的框架的每个应用程序都选中了该复选框时,您正在执行的操作才有效。

© www.soinside.com 2019 - 2024. All rights reserved.