Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to prevent a touch event passed to a UIView's superview?

I've made a program which contains pictures that can be dragged to move on the screen. also I used UIScrollView since the space is larger than the window. I subclassed UIView as a pictures view to display the picture and handle touches in this class. picture views are added as subviews to the scrollView. but now I have a problem: when I drag the picture, the scrollView moves together with the picture. I'm wondering if there is a way to consume the touches in the picture class to prevent them from passing to superview.

like image 534
CarmeloS Avatar asked Mar 07 '11 08:03

CarmeloS


1 Answers

You should to put your code in "touchesMoved:withEvent:" method of your UIView. If your View will handle this event by yourself, then it should not bubble to superview

like image 109
Nikolay Osaulenko Avatar answered Oct 29 '22 00:10

Nikolay Osaulenko