Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow swiping on iOS 13 page sheet #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Source/GestureControl/GestureControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down