Conflicting gesture recognizers in a UITableView

I have two custom controls on mine UIView, one of which is the currently popular sliding menu (when you click on the NavBarslide on the right slide), and the other on UITableViewCellis a user TableViewCellcontrol called DMSlidingTableViewCell (as in Twitter ) when you move the cell to the left, it shows some buttons, etc.)

They work very well, but when I try to add a gesture recognizer to the entire UITableView, thereby making the entire view an area for UIGestureRecognizer(so when I move it, I can move the view to the right) the gesture recognizers somehow conflict.

What could be the reason?

+3
source share
2 answers

I don’t understand how you think that two gesture recognizers can work together in this context, but I think you could try looking at

gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:

delegation method .

Keep in mind that you have 2 gestures, so there are 2 delegates (conceptually, they are implemented by the same method), so you can make one gesture (the first argument) always return NO, and the other YES and see if you can make 2 gesture recognizers work together satisfactorily.

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {

    if ([gestureRecognizer.view isKindOfClass:[UITableView class]]) {
       ...
    } else {
       ...
    }
}

, ( , ), 2 , , .

+6

UIGestureRecognizer UITableView, , u., "cancelsTouchesInView" UIGestureRecognizer .

  UIGestureRecognizer* tapGesture = [[UIGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
  **tapGesture.cancelsTouchesInView = NO;**//pass touch event to others

!

+5

All Articles