Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone UIView touchesMoved: withEvent: does not get called on UIView with gesture recognizers

I added a UIView that relied on TouchesMoved: events to drag touches. There's a long press, tap, rotate and pinch gesture recognizers already present within the same view controller. I'm running into an issue where the view receives touchesBegan: and touchesEnded: events, but no touches moved.

Is my issue with touchesMoved not being called being caused by gesture recognizers cancelling touches within the view? I also got a scroll view involved. Could that be the culprit?

If I will not be able to use touchesMoved, which is the closest gesture to implement the "touch and move" functionality. Is it tap or pan gesture recognizer?

Thank you for your help!

like image 939
Alex Stone Avatar asked Apr 26 '12 01:04

Alex Stone


2 Answers

Mixing raw touch handling with gesture recognizers might yield strange behaviors, at least I was not able to get it working solidly, it was somewhat flaky. In your situation, you might just want to add a drag gesture recognizer (UIPanGestureRecognizer) to the view to handle the drags.

You can control the mechanism of which gesture recognizers fire in which situations by looking into gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: of UIGestureRecognizerDelegate.

like image 31
Jaanus Avatar answered Sep 26 '22 17:09

Jaanus


Gestures by default cancel the touches in the object they are linked to when they are active. You can stop this behavior by setting the cancelsTouchesInView property to NO.

like image 108
borrrden Avatar answered Sep 24 '22 17:09

borrrden