【问题标题】:How to enable or disable landscape mode for specific ViewControllers?如何启用或禁用特定 ViewController 的横向模式?
【发布时间】:2021-02-03 09:34:01
【问题描述】:

我在 Xcode 中启用了横向左右模式。

如何启用或禁用特定 ViewController 的横向模式?

对于一些 VC,我需要横向模式,而对于一些 VC,我只需要纵向模式。

如何在 Objective C 中以编程方式实现它?

【问题讨论】:

    标签: ios objective-c xcode landscape-portrait


    【解决方案1】:

    在您的视图控制器中,覆盖 supportedInterfaceOrientations 属性

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
            return .landscape
    }
    

    您只需要确保不返回任何与“设备方向”设置冲突的内容,否则应用会崩溃。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 2013-08-13
      • 1970-01-01
      • 2012-07-31
      相关资源
      最近更新 更多