In addition to adding the UITapGestureRecognizer, you need to implement a delegate method and and assign the delegate to the gesture recognizer. First somewhere in your view controller:
UITapGestrueRecognizer *tapRecognizer = ...;
tapRecognizer.delegate = self;
And here is the delegate method to implement:
-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
CGPoint location = [gestureRecognizer locationInView:self.tableView];
NSIndexPath *indexPath = self.tableView indexPathForRowAtPoint:location];
return (indexPath == nil);
}
The delegate method checks if the tap occurred in the cells or not, and if not, it doesn't start recognizing the tap in order to give the table view the chance to interpret the gesture.