How to place ARSCNView in Tabview controller without ARSession freezing?
I am trying to implement ARKit iOS 11 beta in my app (tabbed app). But as stated in the ARKit Session Paused and Not Resuming section , whenever I change the tab to a different view controller and return, the ARSession becomes a hover rather than a resuming.
Is it possible to implement ARSCNView in a tabbed app so that if you come back I can resume ARSession? If so, how do you do it?
+3
source to share
1 answer
Yes, you can:
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()
}
Stop session when the view disappears, and re-session with clearing anchors and resetting tracking when the view reappears. Also, to avoid ASCNView appearing and disappearing, it is better to use popup managers.
For a better user experience, see how Apple made these pop-up screens in their demo project.
+5
source to share