Hello everyone. I have an application in which you can open an AR view by tapping on a button. However, after popping the view from my navigation controller and tapping on the AR button again something unusual happens in the camera feed. I see a sudden appearance of the last frame of my previous ar session. Any ideas?
override func viewDidLoad() {
super.viewDidLoad()
focusSquare = FocusEntity(on: arview, style: .classic(color: .yellow))
setupCoachingOverlay()
}
override func viewWillAppear(_ animated: Bool) {
self.navigationController?.isNavigationBarHidden = true
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIApplication.shared.isIdleTimerDisabled = true
resetTracking()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
arview.session.pause()
}
deinit{
arview.session.delegate = nil
arview.scene.anchors.removeAll()
arview.removeFromSuperview()
arview = nil
}
func resetTracking() {
arview.automaticallyConfigureSession = false
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal, .vertical]
arview.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
arview.scene.addAnchor(anchor)
}