如何在不冻结 ARSession 的情况下将 ARSCNView 放入 Tabview 控制器? [英] How to put ARSCNView in Tabview controller without freezing the ARSession?

查看:39
本文介绍了如何在不冻结 ARSession 的情况下将 ARSCNView 放入 Tabview 控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用程序(选项卡式应用程序)中实现 iOS 11 测试版的 ARKit.但正如 ARKit Session Paused and Not Resuming 线程中所说,每当我更改选项卡到另一个视图控制器并返回,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.

是否可以在选项卡式应用程序中实现 ARSCNView,以便您回来时我可以恢复 ARSession?如果是这样怎么办?

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?

推荐答案

是的,您可以:

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()
}

当视图消失时停止会话,并在视图出现时清除锚点并重置跟踪重新运行会话.也为了避免出现和消失 ASCNView 最好使用弹出视图控制器.

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.

为了获得更好的用户体验,请在他们的 中查看 Apple 如何处理这些弹出屏幕演示项目

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

这篇关于如何在不冻结 ARSession 的情况下将 ARSCNView 放入 Tabview 控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆