【发布时间】:2019-01-25 06:12:23
【问题描述】:
我在电流UIViewController(我们称之为控制器B)上呈现一个UIViewController(我们称之为控制器A)。我希望控制器 A 以横向显示。当我设置overCurrentContext 时,默认情况下它不会改变方向(我需要向左/向右转动设备),但是,如果我注释overCurrentContext 代码,一切正常。
var landscapeOrientation = false
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
if landscapeOrientation{
return UIInterfaceOrientationMask.landscapeRight
}else{
return UIInterfaceOrientationMask.portrait
}
}
我如何展示新控制器并设置方向。
let delegate = UIApplication.shared.delegate as! AppDelegate
delegate.landscapeOrientation = true
let controller = ToolTipWithCheckImageViewController()
controller.view.backgroundColor = .clear
controller.modalPresentationStyle = .overCurrentContext //Which causes the bug
controller.modalTransitionStyle = .crossDissolve
topController.present(controller, animated:true)
P.S:我也在其他一些控制器上使用了这个delegate.landspaceOrientation=true,因为我没有使用overCurrentContext 来呈现它,所以一切正常,所以该代码没有问题:)
P.S2:父控制器是UINavigationController
我认为这个问题对我有一些问题,但我无法弄清楚所提供的解决方案。 Can a viewcontroller presented modally over current context (UIModalPresentationStyleOverCurrentContext) be rotated with device?
【问题讨论】:
标签: ios swift orientation