问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/45056160/how-to-put-arscnview-in-tabview-controller-without-freezing-the-arsession