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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With