Search code examples
objective-cuitableviewuiswipegesturerecognizer

swipe guesture for tableview


I have added tableview as subview and I have added swipe gesture to tableview. Swipe is not working. Pan gesture is working fine (just tested). Swipe gesture it not working. I wanna move the table to the right. So I wanna trigger animation only when swipe right is recognized. but swipe itself is not recognized.

panelGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(closePanel:)];
   [panelGesture setDirection: UISwipeGestureRecognizerDirectionRight];

    [panel addGestureRecognizer:panGesture];

Solution

  • When you use more then one gesture recognizer then you need to implement following delegate method of the gesture recognizer to make them work both

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

    respectively you need to return YES