Skip to content

Commit a803fa7

Browse files
authored
Merge pull request #2 from JerwinPRO/fix/ME-8481
Changes for method access level for handle swipe and simplified selector
2 parents ca5a8f3 + 46abf3e commit a803fa7

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Sources/SlideshowGallery/ZoomAnimatedTransitioning.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,27 @@ class ZoomAnimatedTransitioningDelegate: NSObject, UIViewControllerTransitioning
3737

3838
initialize()
3939
}
40-
40+
4141
func initialize() {
4242
// Pan gesture recognizer for interactive dismiss
43-
gestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(ZoomAnimatedTransitioningDelegate.handleSwipe(_:)))
43+
gestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handleSwipe(_:)))
4444
gestureRecognizer.delegate = self
45+
4546
// Append it to a window otherwise it will be canceled during the transition
46-
UIApplication.shared.keyWindow?.addGestureRecognizer(gestureRecognizer)
47+
if #available(iOS 13.0, *) {
48+
// Find the active foreground window scene and its key window
49+
if let windowScene = UIApplication.shared.connectedScenes
50+
.compactMap({ $0 as? UIWindowScene })
51+
.first(where: { $0.activationState == .foregroundActive }),
52+
let window = windowScene.windows.first(where: { $0.isKeyWindow }) ?? windowScene.windows.first {
53+
window.addGestureRecognizer(gestureRecognizer)
54+
}
55+
} else {
56+
UIApplication.shared.keyWindow?.addGestureRecognizer(gestureRecognizer)
57+
}
4758
}
4859

49-
@objc func handleSwipe(_ gesture: UIPanGestureRecognizer) {
60+
@objc private func handleSwipe(_ gesture: UIPanGestureRecognizer) {
5061
guard let referenceSlideshowController = referenceSlideshowController,
5162
let refView = referenceSlideshowView else {
5263
return

0 commit comments

Comments
 (0)