我的 View 由导航 Controller 控制,所以我将导航 Controller 中支持的方向设置为显式纵向和纵向向上侧向下,这有效,但是如果调用 View 时前一个 View 处于横向,它将显示本身处于横向状态并保持横向状态直到设备旋转。我该如何防止这种情况发生?
这是我的代码:
class EditProfileViewController: UIViewController, UINavigationControllerDelegate
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.delegate = self
}
func navigationControllerSupportedInterfaceOrientations(navigationController: UINavigationController) -> UIInterfaceOrientationMask {
return [UIInterfaceOrientationMask.Portrait, UIInterfaceOrientationMask.PortraitUpsideDown]
}
我认为上一行会将 View 永久锁定为纵向,我该怎么做?
最佳答案
您可以在关闭之前将方向改回纵向:
UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation")
dismiss(animated: true) { _ in
print("dismissed in Portrait mode")
}
关于ios - 为什么我的 View 仍然以横向呈现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32707641/