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

Prevent drop down to dismiss gesture in modal presentations (iOS 13) #51

Open
wants to merge 3 commits 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
9 changes: 9 additions & 0 deletions Sources/TouchDrawView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,15 @@ open class TouchDrawView: UIView {

extension TouchDrawView {

open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
// This prevents the drop down to dismiss gesture in modal presentations from iOS 13 on.
// See also: https://stackoverflow.com/questions/56718552/disable-gesture-to-pull-down-form-page-sheet-modal-presentation
if gestureRecognizer is UIPanGestureRecognizer {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just return !(gestureRecognizer is UIPanGestureRecognizer)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. This is just personal preference by me, to make it super easy to understand. I try to prevent ! negations, because you can overlook it so easily...
But you can change it, if you want!

return false
}
return true
}

/// Triggered when touches begin
override open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if let touch = touches.first {
Expand Down