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

DismissOnSwipeOutsideInAllDirections #102

Open
kevinfur opened this issue Feb 21, 2017 · 13 comments
Open

DismissOnSwipeOutsideInAllDirections #102

kevinfur opened this issue Feb 21, 2017 · 13 comments

Comments

@kevinfur
Copy link

Hello.

I'm having an issue with this feature (#42)

I need to close the PopTip if the user swipes in any direction but now it only supports one direction (up/down/right/left) in swipeRemoveGestureDirection.

Don't you think it could be useful to change it to support multiple directions? Also, maybe, add a new configuration called shouldDismissOnSwipeOutsideInAllDirections so we don't break compatibility?

Thank you.

Regards.

@jeffscaturro-wf
Copy link
Contributor

Have you tried something like (UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionUp)?

@kevinfur
Copy link
Author

Nice Jeff! I thought that the variable was an Enum.

I'm coding with Swift and it works with:

popTip.swipeRemoveGestureDirection = [.left, .up, .right, .down]

but the problem is that I'm using the Tip inside a TableCell and it works with right/left swipe, but when I do an up/down swipe the table scroll but the tip doesn't close :(

@jeffscaturro-wf
Copy link
Contributor

I think that will be related to having a UISwipeGestureRecognizer in a UITableView and unrelated to this feature, as it sounds like the scroll gesture is being triggered and not the swipe gesture. It would be an issue with this feature if the swipe gesture was also being triggered. Have you verified the swipe gesture is being triggered?

@kevinfur
Copy link
Author

I didn't verifiy that.
Actually, I added the tip to the controller.view, so the tip is above all, but behind it I have the table.
When I swipe left/right it works, but up/down it doesn't and the table scroll.
When I do the swipes in the navigation bar the tip closes always.
The problem appears when there is a table behind the tip, so I don't know if it is a bug from the tip or a bug from my code 🤔
What do you think?

@jeffscaturro-wf
Copy link
Contributor

Right, I suspect that the table view is intercepting the swipe (where in the other cases you mentioned it is not - which is expected behavior). I would suggest verifying if the swipe gesture is being triggered (via a breakpoint for example). I do not expect it to be a bug in AMPopTip.

@andreamazz
Copy link
Owner

Hey @kevinfur
It might help to set the delegate to the gesture and respond true to the shouldRecognizeSimultaneouslyWithGestureRecognizer function.

BTW, thanks for the help @jeffscaturro-wf

@kevinfur
Copy link
Author

Hello @andreamazz

I tried to set the delegates to the self.tableView.gestureRecognizers but I can't because it says "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'UIScrollView's built-in pan gesture recognizer must have its scroll view as its delegate.'"

:(

Thanks. I will keep thinking.

@andreamazz
Copy link
Owner

Yeah @kevinfur, sorry i wasn't clear. You'll need to set the delegate on the poptip's gesture.

@kevinfur
Copy link
Author

I tried that also but it didn't work

@kevinfur
Copy link
Author

if let gestures = popTip.gestureRecognizers {
            for gesture in gestures.enumerated() {
                gesture.element.delegate = self
            }
        }

And

extension MyView: UIGestureRecognizerDelegate {
    
    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
        return true
    }
    
}

@andreamazz
Copy link
Owner

The gestures are binded to the poptip's containerView though.

@YaphetS1
Copy link

Same issue, in collection view, what to do with it?

@TarasGordienko
Copy link

Setting gesture recognizers worked for me, however gesture recognizer cannot handle 4 directions - https://stackoverflow.com/questions/7420078/detect-when-uigesturerecognizer-is-up-down-left-and-right-cocos2d/7760927#7760927

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

No branches or pull requests

5 participants