From 4c8d796b8a7eeae3a86ff7506de463fbed0faf80 Mon Sep 17 00:00:00 2001 From: Zheng <49819455+zjohnzheng@users.noreply.github.com> Date: Tue, 7 Jul 2020 12:03:31 -0700 Subject: [PATCH] Allow swiping on iOS 13 page sheet Conform to gestureRecognizer(_:shouldBeRequiredToFailBy:) Details at https://developer.apple.com/documentation/uikit/uigesturerecognizerdelegate/1624222-gesturerecognizer --- Source/GestureControl/GestureControl.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/GestureControl/GestureControl.swift b/Source/GestureControl/GestureControl.swift index 0c01a36..c9f504a 100644 --- a/Source/GestureControl/GestureControl.swift +++ b/Source/GestureControl/GestureControl.swift @@ -26,10 +26,12 @@ public class GestureControl: UIView { swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(GestureControl.swipeHandler(_:))) swipeLeft.direction = .left + swipeLeft.delegate = self /// reference the gesture recognizer delegate addGestureRecognizer(swipeLeft) swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(GestureControl.swipeHandler(_:))) swipeRight.direction = .right + swipeRight.delegate = self /// reference the gesture recognizer delegate addGestureRecognizer(swipeRight) translatesAutoresizingMaskIntoConstraints = false @@ -50,6 +52,18 @@ public class GestureControl: UIView { } } +// MARK: Gesture recognizer delegate +/// the default modal presentation style in iOS 13 is a page sheet +/// if Paper Onboarding is presented as a page sheet, this function is **required to enable swiping** +/// because there is a built-in gesture (that dismisses the page sheet) which conflicts with the swipe gesture +/// +/// with this function, **both the swipe gesture and the built-in gesture work!** +extension GestureControl: UIGestureRecognizerDelegate { + public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool { + return true + } +} + // MARK: actions extension GestureControl {