diff --git a/Sources/CodeScanner/ScannerViewController.swift b/Sources/CodeScanner/ScannerViewController.swift index dc47fa3..af7fa5c 100644 --- a/Sources/CodeScanner/ScannerViewController.swift +++ b/Sources/CodeScanner/ScannerViewController.swift @@ -12,7 +12,7 @@ import UIKit @available(macCatalyst 14.0, *) extension CodeScannerView { - public class ScannerViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, AVCaptureMetadataOutputObjectsDelegate { + public class ScannerViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, AVCaptureMetadataOutputObjectsDelegate, UIAdaptivePresentationControllerDelegate { private let photoOutput = AVCapturePhotoOutput() private var isCapturing = false private var handler: ((UIImage) -> Void)? @@ -46,6 +46,7 @@ extension CodeScannerView { isGalleryShowing = true let imagePicker = UIImagePickerController() imagePicker.delegate = self + imagePicker.presentationController?.delegate = self present(imagePicker, animated: true, completion: nil) } @@ -92,6 +93,11 @@ extension CodeScannerView { dismiss(animated: true, completion: nil) } + public func presentationControllerDidDismiss(_ presentationController: UIPresentationController) { + // Galery is no longer being presented + isGalleryShowing = false + } + #if targetEnvironment(simulator) override public func loadView() { view = UIView()