I had come across a problem which didSelectRowAtIndexPath doesn’t execute when I tap the cell.

1
2
3
4
5
6
7
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Successfully tapped");
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

No matter how I tap, it doesn’t show the log.

Attributes Inspector

As shown in the attribute inspector, the Selection is not none, User Interaction Enabled is also checked.

Finally, I found the problem…

1
2
3
4
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
return nil;
}

I forgot to remove willSelectRowAtIndexPath in ViewController.