Incorrect value returned by -[UITableView indexPathForRowAtPoint]

Originator:thomas.auchter
Number:rdar://13187897 Date Originated:2/10/13
Status:Open Resolved:
Product:iPhone SDK Product Version:6.1.1
Classification:Other Bug Reproducible:Always
 
Summary:
In a UITableView (either grouped or plain) with multiple sections, -indexPathForRowAtPoint returns null correctly for a point in the first section header view, but for points in subsequent section headers it returns the index path for the first row in the section.  


Steps to Reproduce:
1. New project, table view controller as the initial view controller.
2. table view datasource returns 2 sections, 3 rows per section, and section titles "Section 0" and "Section 1" for the sections.
3. Add UITapGestureRecognizer to the tableview.  
4. When Tap gesture recognizer fires, call:
- (void)tapped:(id)sender {
    UITapGestureRecognizer *t = (UITapGestureRecognizer *)sender;
    
    CGPoint touchLoc = [t locationInView:t.view];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:touchLoc];
    
    NSLog(@"indexPath: %@", indexPath);
}
5. Run app, and tap in the headers of each section, as well as the rows.

Expected Results:
When tapping in a section header, the indexPath should be null.

Actual Results:
When tapping in the first section header, the indexPath is null.

When tapping in the second section header, the indexPath is not null, but is [1, 0] instead (the first row in that section).

Regression:

Notes:
Sample TableViewController code is attached.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!