0

I am using a tap gesture on my view which also has a table view as a subview. The table does scroll but when tapped, instead of calling didSelectRowAtIndexPath it calls the selector associated with the tap gesture. I can detect the tapped view by getting tap location. I want to access didSelectRowAtIndexPath when tapped on table instead of the tap gesture selector. How do I achieve this?

Unheilig
  • 16,196
  • 193
  • 68
  • 98
brainforked
  • 139
  • 1
  • 16
  • Check http://stackoverflow.com/questions/8192480/uitapgesturerecognizer-breaks-uitableview-didselectrowatindexpath – kb920 Dec 25 '13 at 05:43

1 Answers1

4

Implement the tap gesture's UIGestureRecognizerDelegate , and prevent the gesture if touch is in the tableview.

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    CGPoint p = [gestureRecognizer locationInView:view] ;
    if (CGRectContainsPoint(tableview.frame, p)) {
        return NO ;
    }
    return YES ;
}
KudoCC
  • 6,912
  • 1
  • 24
  • 53