ios - -didSelectRowAtIndexPath: not being called

ID : 10137

viewed : 24

Tags : iosuitableviewcocoa-touchdidselectrowatindexpathios

Top 5 Answer for ios - -didSelectRowAtIndexPath: not being called

vote vote


Just in case someone made the same stupid mistake as I did:

Check out if the method name of what you expect of being didSelect may accidentally be gotten didDeselect in some way. It took about two hours for me to find out ...

vote vote


Another thing that might lead to the issue is not selected selection kind:

UITableView selection kind

Should be Single Selection for normal selection, should not be No Selection.

To do this programmatically, do:

tableView.allowsSelection = YES 
vote vote


Another possibility is that a UITapGestureRecognizer could be eating the events, as was the case here:

I didn't suspect this cause, because the table cells would still highlight blue as if the taps were getting through.

vote vote


All good answers, but there's one more to look out for...

(Particularly when creating a UITableView programmatically)

Make sure the tableView can respond to selection by setting [tableView setAllowsSelection:YES]; or removing any line that sets it to NO.

vote vote


It sounds like perhaps the class is not the UITableViewDelegate for that table view, though UITableViewController is supposed to set that automatically.

Any chance you reset the delegate to some other class?

Top 3 video Explaining ios - -didSelectRowAtIndexPath: not being called