如何在不自动旋转的情况下设置指定的页面旋转?我发现只有在var shouldAutorotate
返回yes时屏幕才能旋转,但我不想自动这样做,我想自己控制旋转的时刻
问问题
40 次
1 回答
0
斯威夫特 4+:
在需要时使用以下代码旋转屏幕,而无需根据需要进行任何自动旋转。
func rotateToLandscapeRight() {
UIDevice.current.setValue(UIInterfaceOrientation.landscapeRight.rawValue, forKey: "orientation")
}
func rotateToLandscapeLeft() {
UIDevice.current.setValue(UIInterfaceOrientation.landscapeLeft.rawValue, forKey: "orientation")
}
func rotateToPortratit() {
UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation")
}
于 2019-05-14T08:52:36.370 回答