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

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

问题描述

我正在尝试在我的应用程序(Tabbed应用程序)中实现iOS 11 beta的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天全站免登陆