我有一個類如下
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 方向時旋轉。
uj5u.com熱心網友回復:
如果您想防止所有代碼中的旋轉,您可以嘗試:進入 info.plist,轉到“支持的界面方向(iPad)”或“支持的界面方向(iPhone)”,打開一個帶有顯示三角形的部分并洗掉您不想為 iPad/iPhone 旋轉的專案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/362383.html
上一篇:SwiftUI-雙`.clipped()`修飾符使視圖消失
下一篇:Swift委托模式:委托=Nil
