我有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函数后,会显示新屏幕,但摄像机视图的方向错误。