我有一个类,如下所示
class ViewController: UIViewController, ARSCNViewDelegate, SCNPhysicsContactDelegate {
@IBOutlet var sceneView: ARSCNView!如何防止sceneView旋转?
我尝试了很多方法,比如
添加
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.portrait
}
override var shouldAutorotate: Bool {
return false
}在UIViewController中
或添加
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.portrait
}在应用程序委派中
或设置

或设置

并不是所有的都能正常工作。
当我在ipad上运行它时,当我改变ipad的方向时,它总是会旋转。
发布于 2021-11-20 00:30:16
如果你想在你所有的代码中防止旋转,你可以尝试:在info.plist中,转到“支持的界面方向(iPad)”或“支持的界面方向(iPhone)",打开一个带有展开三角形的部分,删除那些你不想在iPad/iPhone上旋转到的项目。
https://stackoverflow.com/questions/70041970
复制相似问题