我有 viewController 1,它用 ARSCNView 呈现 viewController。在 viewControllers 的事务之间,方向发生了变化,所有的 UI 方向都在该位置,但 ARSCNView 相机视图位于错误的位置
(视图框架在当前位置,但相机视图倒置或向左)
当我将手机旋转到纵向并返回所有外观时。
ARSCNView 在自定义视图中
class MyARSceneView :UIView { @IBOutlet private weak var sceneView: ARSCNView! private func loadViewFromNib() -> UIView { let bundle = Bundle(for: type(of: self)) let nib:UINib = UINib(nibName: self.nibName, bundle: bundle) // Assumes UIView is top level and only object in CustomView.xib file let view = nib.instantiate(withOwner: self, options: nil)[0] as! UIView return view } .... }
ARViewContoller:
class ARViewController : UIViewController { @IBOutlet weak var arSceneView: FBARSceneView! override func viewDidLoad() { appDelegate.enableAllOrientation = true super.viewDidLoad() } func presentARViewController() { self.annotationView = UIStoryboard.arViewController() viewController.present(annotationView!, animated: true) { self.setUpARViewController() completion?() } }
在 appDeleagte 中:
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { if enableAllOrientation == true { return UIInterfaceOrientationMask.allButUpsideDown } return UIInterfaceOrientationMask.portrait }
调用 presentARViewController 函数后,会显示新屏幕,但相机视图的方向错误。