【发布时间】:2018-04-01 08:16:59
【问题描述】:
我有适用于 iPhone 和 iPad 的应用程序。但是,对于 iPad,我只能强制横向使用,对于 iPhone,我没有任何限制。
据我了解,这样的解决方案不能通过项目属性中的设备方向属性来完成,我必须为 iPhone 全部选择,并且必须通过代码。
我是 Swift 的新手,很高兴得到一些解释。
【问题讨论】:
标签: ios iphone xcode ipad swift4
我有适用于 iPhone 和 iPad 的应用程序。但是,对于 iPad,我只能强制横向使用,对于 iPhone,我没有任何限制。
据我了解,这样的解决方案不能通过项目属性中的设备方向属性来完成,我必须为 iPhone 全部选择,并且必须通过代码。
我是 Swift 的新手,很高兴得到一些解释。
【问题讨论】:
标签: ios iphone xcode ipad swift4
你可以试试
if(UIDevice.currentDevice().userInterfaceIdiom == .Pad){
let value = UIInterfaceOrientation.LandscapeRight.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
}
【讨论】: