From 46abf3ebd880a7d09f7aab47c243b47339aff2ec Mon Sep 17 00:00:00 2001 From: Jerwin Pastoral Date: Thu, 8 Jan 2026 15:11:14 +0800 Subject: [PATCH] Changes for method access level and simplified selector --- .../ZoomAnimatedTransitioning.swift | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Sources/SlideshowGallery/ZoomAnimatedTransitioning.swift b/Sources/SlideshowGallery/ZoomAnimatedTransitioning.swift index c6bdde6..02b41c1 100644 --- a/Sources/SlideshowGallery/ZoomAnimatedTransitioning.swift +++ b/Sources/SlideshowGallery/ZoomAnimatedTransitioning.swift @@ -37,16 +37,27 @@ class ZoomAnimatedTransitioningDelegate: NSObject, UIViewControllerTransitioning initialize() } - + func initialize() { // Pan gesture recognizer for interactive dismiss - gestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(ZoomAnimatedTransitioningDelegate.handleSwipe(_:))) + gestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handleSwipe(_:))) gestureRecognizer.delegate = self + // Append it to a window otherwise it will be canceled during the transition - UIApplication.shared.keyWindow?.addGestureRecognizer(gestureRecognizer) + if #available(iOS 13.0, *) { + // Find the active foreground window scene and its key window + if let windowScene = UIApplication.shared.connectedScenes + .compactMap({ $0 as? UIWindowScene }) + .first(where: { $0.activationState == .foregroundActive }), + let window = windowScene.windows.first(where: { $0.isKeyWindow }) ?? windowScene.windows.first { + window.addGestureRecognizer(gestureRecognizer) + } + } else { + UIApplication.shared.keyWindow?.addGestureRecognizer(gestureRecognizer) + } } - @objc func handleSwipe(_ gesture: UIPanGestureRecognizer) { + @objc private func handleSwipe(_ gesture: UIPanGestureRecognizer) { guard let referenceSlideshowController = referenceSlideshowController, let refView = referenceSlideshowView else { return