Niloufar
Niloufar

Reputation: 532

Table View selection and pan gesture

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?

Upvotes: 2

Views: 2274

Answers (1)

Vizllx
Vizllx

Reputation: 9246

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.

Upvotes: 3

Related Questions