我想要建立一个应用程序,用户可以在不同的AR视图之间滑动填充不同的内容,,但在相同的AR会话-所以他们不需要每次搜索飞机/功能。
我试着通过单例将ARSCNView从一个ViewController传递到另一个ViewController。但这给了我一个错误:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key sceneView.'在这种情况下,正确的模式是什么?
MainViewController:
extension MainViewController: ARSCNViewDelegate, ARSessionDelegate
{
func initAR(){
ArSceneView.delegate = self
ArSceneView.scene = scene
ArSceneView.debugOptions = [ARSCNDebugOptions.showFeaturePoints]
MainViewController.manager.ArSession=ArSceneView
}
override func viewWillAppear(_ animated: Bool) {
let configuration = ARWorldTrackingConfiguration()
ArSceneView.session.run(configuration)
}
}AnotherViewController:
class AnotherViewController: {
override func viewDidLoad() {
MainViewController.manager.ArSession.delegate = self
}
}编辑:我已经找到了一个解决办法--如果您想在不同的ViewControllers上使用相同的AR会话,请随意使用UIPageViewController,并对其使用SCNView,然后在连接到UIPageViewController的不同视图中保持不变。
发布于 2018-01-12 08:19:17
这个话题本身就很有趣。因此,我尝试在prepareForSeague中简单地将场景视图、会话从一个视图传递到下一个视图控制器。它切换时没有任何错误,但是sceneview是空的。现在我不确定它是重置了还是完全重新开始了。我真的很想知道你的是否有效。
对于您的问题--如果您的AnotherViewController中没有任何其他特定功能,则可以在内容之间滑动。
https://stackoverflow.com/questions/48213611
复制相似问题