I have implemented UITableView where each cell contains some buttons In order to detect if user taps on table I have added UITapGestureRecognizer.
I want the buttons in the cells to do nothing when user taps on them. I have implemented this selector:
- (void) backgroundTouched:(UITapGestureRecognizer*)sender {
UIView *view = sender.view;
NSLog(@"backgroundTouched %@", view);
}
I see that when I tap anywhere on the table this selector gets called except if I tap on any of the buttons contained in the UITableViewCell.
How can I avoid that?
Here is the code which creates the UITapGestureRecognizer:
pragma mark UISearchControllerDelegate
- (void)didPresentSearchController:(UISearchController *)searchController
{
NSLog(@"didPresentSearchController");
self.cancelGesture = [UITapGestureRecognizer new];
[self.cancelGesture addTarget:self action:@selector(backgroundTouched:)];
self.cancelGesture.cancelsTouchesInView = YES;
[self.tableView addGestureRecognizer:self.cancelGesture];
}