Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable the automatic activation of an ARCoachingOverlayView?

I am adding an ARCoachingOverlayView to my ARView like this

let coachingOverlayTemp = ARCoachingOverlayView()
coachingOverlayTemp.delegate = self
coachingOverlayTemp.session = self.session
coachingOverlayTemp.goal = .horizontalPlane
coachingOverlayTemp.activatesAutomatically = true
coachingOverlayTemp.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(coachingOverlayTemp)

coachingOverlay = coachingOverlayTemp // I store it to a variable on the class

Later, If I do

coachingOverlay.activatesAutomatically = false

has no effect. coachingOverlay continues to work normally.

How do I disable it immediately when I want?

like image 307
John Doe Avatar asked Oct 25 '25 02:10

John Doe


1 Answers

An instance method setActive(_:animated:) controls whether coaching is in progress or not.

open func setActive(_ active: Bool, animated: Bool)

Here's what Apple documentation says:

If the animated property of setActive(_:animated:) is true, isActive and isHidden are false while the coaching overlay is fading out. When the coaching overlay is deactivated without animation, or when the animation finishes, ARKit notifies you by calling coachingOverlayViewDidDeactivate(_:).

// SMOOTHLY
ARCoachingOverlayView().setActive(false, animated: false)

Or as alternative you can use isHidden property:

// ABRUPTLY
ARCoachingOverlayView().isHidden = true
like image 73
Andy Jazz Avatar answered Oct 26 '25 23:10

Andy Jazz