【问题标题】:xCode: Force orientation for iPadxCode:iPad 的强制方向
【发布时间】:2018-04-01 08:16:59
【问题描述】:

我有适用于 iPhone 和 iPad 的应用程序。但是,对于 iPad,我只能强制横向使用,对于 iPhone,我没有任何限制。

据我了解,这样的解决方案不能通过项目属性中的设备方向属性来完成,我必须为 iPhone 全部选择,并且必须通过代码。

我是 Swift 的新手,很高兴得到一些解释。

【问题讨论】:

    标签: ios iphone xcode ipad swift4


    【解决方案1】:

    你可以试试

        if(UIDevice.currentDevice().userInterfaceIdiom == .Pad){
    
            let value = UIInterfaceOrientation.LandscapeRight.rawValue
            UIDevice.currentDevice().setValue(value, forKey: "orientation")
    
    
        }
    

    【讨论】:

      【解决方案2】:

      我在 Info.plist 中找到了这些选项 效果很好!

      【讨论】:

        猜你喜欢
        • 2011-03-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-02-29
        • 2018-10-13
        相关资源
        最近更新 更多