Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

iPhone 16 Camera Control and AVCaptureSlider – Is there a way to detect which slider is active?

I am following the Apple sample code and trying to add a manual focus lens position slider:

@available(iOS 18.0, *)
private func addCameraControls() {
   
       if !self.session.controls.isEmpty {
           for control in self.session.controls {
               self.session.removeControl(control)
           }
       }
       
       self.cameraControlFocusSlider = nil

       //Focus Slider
       if self.videoDevice!.isLockingFocusWithCustomLensPositionSupported {
           self.cameraControlFocusSlider = AVCaptureSlider("Focus", symbolName: "dot.square", in: 0.0...1.0)
           self.cameraControlFocusSlider!.setActionQueue(self.sessionQueue) { focusValue in
               
             //Do manual focus
               
               
           }
           if self.session.canAddControl(self.cameraControlFocusSlider!) {
               self.session.addControl(self.cameraControlFocusSlider!)
           }
       }
}

So there are these AVCaptureSessionControlsDelegate methods:

final func sessionControlsDidBecomeActive(_ session: AVCaptureSession) {
        print ("sessionControlsDidBecomeActive")

    }
    
    final func sessionControlsWillEnterFullscreenAppearance(_ session: AVCaptureSession) {
        print ("sessionControlsWillEnterFullscreenAppearance")

    }
    
    final func sessionControlsWillExitFullscreenAppearance(_ session: AVCaptureSession) {
        print ("sessionControlsWillExitFullscreenAppearance")

    }
    
    final func sessionControlsDidBecomeInactive(_ session: AVCaptureSession) {
        print ("sessionControlsDidBecomeInactive")

    }

So when self.cameraControlFocusSlider is presented, I have to show the current value of the lense position. Lens position can change from auto focus and also from manual focus by the user using the app UI. Is there a way to see if self.cameraControlFocusSlider is active or being used?

Please note that I will have more than one AVCaptureSlider in the final code.

iPhone 16 Camera Control and AVCaptureSlider – Is there a way to detect which slider is active?
 
 
Q