我正在尝试在我的应用程序(Tabbed 应用程序)中实现 iOS 11 beta 的 ARKit。但正如ARKit Session Paused and Not Resuming中所说线程,每当我将选项卡更改为另一个 View Controller 并返回时,ARSession 就会卡住并且不会恢复。
是否可以在选项卡式应用程序中实现 ARSCNView,以便如果您回来我可以恢复 ARSession?如果是这样怎么办?
最佳答案
是的,你可以:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let configuration = ARWorldTrackingSessionConfiguration()
sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
sceneView.session.pause()
}
当 View 消失时停止 session ,并在 View 出现时通过清除 anchor 和重置跟踪重新运行 session 。还要避免出现和消失 ASCNView 更好地使用弹出 View Controller 。
为了获得更好的用户体验,请参阅 Apple 如何在其 demo project 中制作这些弹出屏幕
关于ios - 如何在不卡住 ARSession 的情况下将 ARSCNView 放入 Tabview Controller 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45056160/