【发布时间】:2016-06-03 21:07:52
【问题描述】:
我希望我的应用可以在 iPad 上以所有方向运行,在 iPhone 6 Plus 上支持横向和纵向,在其他设备上只支持纵向。
但它在 iPhone 6/6s Plus 上无法正常工作。旋转很奇怪,视图控制器经常以错误的方向显示自己。
这是我目前在我的AppDelegate.swift 中拥有的:
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
let height = window?.bounds.height
if height > 736.0 {
// iPad
return .All
} else if height == 736.0 {
// 5.5" iPhones
return .AllButUpsideDown
} else {
// 4.7", 4", 3.5" iPhones
return .Portrait
}
}
这样做的正确方法是什么?
【问题讨论】:
标签: ios iphone swift ipad orientation