2
votes

I have a table view with a pan gesture on it. When I start panning the tableview up and down the tableView selection gets disable and I can't select tableview cells.

UIPanGesture* tablePanGesture =[[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(gestureHandler:)];
tablePanGesture.delegate = self;
[tableView addGestureRecognizer:tablePanGesture];
[tablePanGesture setCancelsTouchesInView:NO];

And I using the following delegate to let my gestures and tableview gestures work together:

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

    return YES;
}

I have implemented the method for table view didSelectRowAtIndexPath but when I use panning it is not called. Is there any conflict between pan gesture and tableview Delegate?

1
why are you using pan gesturesLalit Kumar
@LalitKumar I want to pan the table up and then enable the scroll and then pan it down if the content offset is zero and table is dragging.Niloufar
What is purpose of doing this ??Nirav Gadhiya
@NJGadhiya I have a tableview which shows a list to user and I want the user to be able to shrink the tableview and then scroll itNiloufar
You can use UIScrollViewDelegate method to detect up/down scroll of UITableView. So you can remove the pan gesture if the scroll delegate did the purpose.Akhilrajtr

1 Answers

3
votes

You are missing this line:-

[tablePanGesture setCancelsTouchesInView:NO];

This will let the UIPanGesture recognize the pan gesture and also pass the touch to the next responder means your table view select or tap.