Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conflicting UITapGestureRecognizer in UIView and for UITableView

Tags:

I have a UIView in which I added a UITapGestureRecognizer. Inside that view I also have a subview in which is basically some kind of a UITableView. The question is that why doesn't the UITableView recognizes the tap on a row, instead it goes to the tap gesture recognizer's handler all the time. Why is this, and how do I solve this? If I set the number of taps to 2, then it works fine. Any idea on how to solve this? Basically it doesn't call the didSelectRowAtIndexPath.

like image 448
adit Avatar asked Jan 18 '12 02:01

adit


1 Answers

Set cancelsTouchesInView of your recognizer to NO. Otherwise, it "consumes" the touch for itself, and does not pass it on to the table view. That's why the selection event never happens.

like image 158
Sergey Kalinichenko Avatar answered Oct 18 '22 07:10

Sergey Kalinichenko