gpt4 book ai didi

ios - 如何旋转屏幕, `var shouldAutorotate` 返回 false

转载 作者:行者123 更新时间:2023-11-29 05:46:21 40 4
gpt4 key购买 nike

如何设置指定的页面旋转而不使其自动旋转?我发现只有当var shouldAutorotate返回yes时屏幕才能旋转,但我不想自动旋转,我想自己控制旋转的时刻

最佳答案

swift 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")
}

关于ios - 如何旋转屏幕, `var shouldAutorotate` 返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56121922/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com