I've been officially notified that iOS 17.2 contains the new API to officially support volume button actuation for photo capture in a camera app.
API is called AVCaptureEventInteraction
Link
So If I use the AVCam sample code, How would I be able to attach this interaction?
if #available(iOS 17.2, *) {
let interaction = AVCaptureEventInteraction { event in
print ("AVCaptureEventInteraction Fired")
}
}
API does not contain any details.
AVCaptureEventInteraction implements the UIInterAction protocol. So you should attach the AVCaptureEventInteraction to a UI element (e.g. your shutter button) that is part of the responder chain.
Example:
if #available(iOS 17.2, *) {
let shutterEventInteraction = AVCaptureEventInteraction.init { event in
print(event)
if (event.phase == AVCaptureEventPhase.began) {
self.performCapture()
}
}
shutterEventInteraction.isEnabled = true
self.shutterButton.addInteraction(shutterEventInteraction)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With