如何从Cordova插件锁定屏幕方向?

时间:2017-10-30 04:50:08

标签: ios swift cordova

我正在编写一个Cordova插件,它只是呈现一个UIView控制器。我可以锁定那个UIView的方向,但我还可以锁定其父级的方向吗?

在主要的Cordova课程中

self.storyboard = UIStoryboard(name: "myuiview", bundle: nil)
self.myView = self.storyboard?.instantiateInitialViewController() as? myViewController
self.viewController.present(self.myView!, animated: true) { _ in }
myViewController中的

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    return .portrait
}

override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
    return .portrait
}

这会锁定当前myViewController的方向。但是,当我旋转设备然后dismiss myViewController时,应用程序的方向仍然发生了变化

1 个答案:

答案 0 :(得分:0)

我认为以下帖子也可以解决您的问题。

你可以修改@ bmjohns的回答

How to lock orientation of one view controller to portrait mode only in Swift

相关问题