title: Can't determine section header from point in tableView
body: <p>I have a <code>UIButton</code> receiving an action in each section header in a <code>UITableView</code>. When a tap occurs, I need to be able to get if it hit something that is not a cell so I set his code:</p>
  
  <pre><code>UITouch *touch = [[event touchesForView:deleteButton] anyObject];
  CGPoint location = [touch locationInView:self.tableView];
  if (![self.tableView indexPathForRowAtPoint:location]) {
    //stuff
  }
  </code></pre>
  
  <p>Everytime I tap a section header button, the function returns me the index path of the first row from the corresponding section. In order to figure out what was going on I coded this part</p>
  
  <pre><code>UITouch *touch = [[event touchesForView:deleteButton] anyObject];
  CGPoint location = [touch locationInView:self.tableView];
  NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];
  CGRect frame = [self.tableView rectForRowAtIndexPath:indexPath];
  NSLog(@"\nSection: %ld\nRow:%ld\nTouch: %.f\nRange: %.1f-%.1f\n\n", indexPath.section, indexPath.row, location.y, frame.origin.y, frame.origin.y + frame.size.height);
  </code></pre>
  
  <p>The log returns me this for example:</p>
  
  <p>Section: 1
  Row: 0
  Touch: 192.0
  Range: 220.0-264.0</p>
  
  <p>Meaning that even though the touch was out of the cell's rect it hit an index path. Curious enough, the first section in which also happens this problem, does manage to enter the if-structure.</p>
  
  <p>The important code would be the section header function:</p>
  
  <pre><code>- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *headerView = [UIView new];
    UILabel *headerLabel = [UILabel new];
    headerLabel.frame = CGRectMake(ZTRowPadding, 2.0, CGRectGetWidth(tableView.frame) - 2 * ZTRowPadding - ZTSectionHeaderHeight, 40.0);
    headerLabel.text = [self.wod.wSets[section] fullSizeSectionTitle:NO];
    headerLabel.textColor = [UIColor carbonColorWithAlpha:ZTAlphaLevelFull];
    headerLabel.font = [UIFont fontWithName:@"AvenirNext-Regular" size:13.0];
    headerLabel.numberOfLines = 2;
    [headerView addSubview:headerLabel];
  
    UIButton *deleteButton = [UIButton new];
    deleteButton.frame = CGRectMake(CGRectGetWidth(tableView.frame) - ZTSectionHeaderHeight, 0.0, ZTSectionHeaderHeight, ZTSectionHeaderHeight);
    deleteButton.backgroundColor = [UIColor crimsonColorWithAlpha:ZTAlphaLevelFull];
    [deleteButton setTitle:@"X" forState:UIControlStateNormal];
    [deleteButton setTitleColor:[UIColor ivoryColorWithAlpha:ZTAlphaLevelFull] forState:UIControlStateNormal];
    [deleteButton addTarget:self action:@selector(deleteSectionButtonTapped:forEvent:) forControlEvents:UIControlEventTouchUpInside];
    [headerView addSubview:deleteButton];
  
    return headerView;
  }
  </code></pre>
  
  <p>and the delete button action.</p>
  
  <pre><code>- (void)deleteSectionButtonTapped:(UIButton *)deleteButton forEvent:(UIEvent *)event {
    UITouch *touch = [[event touchesForView:deleteButton] anyObject];
    CGPoint location = [touch locationInView:self.tableView];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];
    CGRect frame = [self.tableView rectForRowAtIndexPath:indexPath];
    NSLog(@"\nSection: %ld\nRow:%ld\nTouch: %.f\nRange: %.1f-%.1f\n\n", indexPath.section, indexPath.row, location.y, frame.origin.y, frame.origin.y + frame.size.height);
  
    if (![self.tableView indexPathForRowAtPoint:location]) {
      for (NSInteger section = 0; section &lt; [self.wod.wSets count]; section++) {
        CGRect headerViewRect = [self.tableView rectForHeaderInSection:section];
        if(CGRectContainsPoint (headerViewRect, location)) {
          ZTWodSet *wodSet = self.wod.wSets[section];
          [self.wod removeObject:wodSet fromOrderedSetWithKey:@"wSets"];
  
          [[ZTDataManager sharedDataManager].mainContext deleteObject:wodSet];
          NSError *error;
          if (![[ZTDataManager sharedDataManager].mainContext save:&amp;error]) {
            NSLog(@"Failed to save data");
            return;
          }
  
          [self.tableView beginUpdates];
          [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:UITableViewRowAnimationFade];
          [self.tableView endUpdates];
          break;
        }
      }
    }
  }
  </code></pre>