Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put ARSCNView in Tabview controller without freezing the ARSession?

I am trying to implement ARKit of iOS 11 beta in my app(Tabbed application). But as said in ARKit Session Paused and Not Resuming thread, whenever i change the tab to another view controller and come back, the ARSession is getting freezed and not resuming.

Is it possible to implement ARSCNView in a tabbed application so that if you come back i can resume the ARSession? If so how to do it?

like image 371
yaali Avatar asked Jul 12 '17 11:07

yaali


1 Answers

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 view will disappear, and rerun session with clearing anchors and resetting tracking when view will appear. Also to avoid appearing and disappearing ASCNView better to use popup view controllers.

For better user experience, see how Apple did those popover screens in their demo project

like image 86
Vasilii Muravev Avatar answered Nov 13 '22 02:11

Vasilii Muravev