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

Conversation

fl034
Copy link
Contributor

@fl034 fl034 commented Dec 4, 2019

When TouchDrawView is embedded in a modal presentation in iOS 13, the user can drag to dismiss. This interferes with the drawing.

This PR fixes that like in the accepted answer here (method no. 3): https://stackoverflow.com/a/57635168/4846592

@dehli
Copy link
Owner

dehli commented Dec 17, 2019

Hey @fl034, thanks for the PR! Sorry I din't see this until now. I will verify on my end and then get it merged 👍

@dehli
Copy link
Owner

dehli commented Dec 19, 2019

@fl034 Are there cases where you'd want to dismiss the view and this will prevent you from being able to?

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!

@fl034
Copy link
Contributor Author

fl034 commented Dec 23, 2019

@fl034 Are there cases where you'd want to dismiss the view and this will prevent you from being able to?

@dehli yeah maybe some user has isUserInteractionEnabled set to false to disable drawing temporarily. We could check for this case in the gestureRecognizerShouldBegin function. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants