views:

227

answers:

2

What I would like to do is to detect a swipe gesture followed by a pan gesture as part of the same touch sequence. So the user first swipes an object to carry out an action, then, while keeping their finger on the screen, moves up/down to propagate the action to surrounding objects.

I have a swipe gesture recognizer and a pan gesture recognizer.

It seems to me that the ideal way to make them behave the way I want is to do this:

[myPanGestureRecognizer requireGestureRecognizerToSucceed:mySwipeGestureRecognizer];

But although I was sure that I hadn't just imagined requireGestureRecognizerToSucceed:, it seems I have.

Is there a way to achieve what I want without subclassing UIGestureRecognizer?

A: 

One (cheap) way to fake it would be to measure the time elapsed between two gestures. While this is not a proper solution it's definitively one that should work. Not a great help I know, but still.

cheers

sam

samsam
This won’t work out of the box since the pan gesture will fail as soon as the swipe succeeds.
Ben Stiglitz
I've not succeeded in getting events from both gestures at the same time. To get two consecutive gestures requires the user to lift their finger and start a new touch sequence so that's out too.
oldbeamer
sorry, that was a missunderstanding then. I thought of doing a swipe first and an pan afterwards.
samsam
A: 

You can do this by setting both the swipe and the pan to recognize simultaneously, and subclassing the pan so that it does actually mark itself as recognized until the swipe has been recognized.

Ben Stiglitz
How do I get them to recognize simultaneously? I've tried with both running but the pan seems to be capturing the touch events.
oldbeamer
Implement `-gestureRecognizer: shouldRecognizeSimultaneouslyWithGestureRecognizer:` in your gesture delegate to return `YES`.
Ben Stiglitz
Thank you Ben, I'd completely missed that.
oldbeamer