【发布时间】:2015-09-23 05:37:00
【问题描述】:
这是我的问题:将 iPhone 6 Plus 或 iPad 旋转到例如LandscapeLeft.
假设您的应用具有以下代码(仅作为示例)
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.Portrait
// mine does use All, but with this case you'll understand my question
}
我如何检测设备何时应该使用垂直或水平布局
func willTransitionToTraitCollection(newCollection: UITraitCollection, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator)
被调用?
print(UIScreen.mainScreen().bounds.width < UIScreen.mainScreen().bounds.height)
// will return false, because we started in landscape but the layout will be forced to be vertical here
print(UIApplication.sharedApplication().statusBarOrientation == .LandscapeLeft)
// will return true, because we started in landscape but the layout will be forced to be vertical here
主要问题出现在 iPad 上,因为两个尺寸等级都是regular。
我很困惑,不知道如何解决这个问题。
【问题讨论】:
标签: ios swift device-orientation