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