Mark
Mark

Reputation: 7576

UITableView cells cannot be selected

When I select a row on my UITableView, the call to the handler is never made...

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

I create the custom cells programmatically. User interaction is enabled on my UITableView and the data source and delegate are set to the File's Owner for the view controller the tale resides in. I am able to insert data, but touches are not detected. The cells do not even turn blue.

What am I missing?

I tried setting the table to allow selection:

   tableView.allowsSelection = YES;

EDIT:

More details - I have a NSLog in the didSelectRowAtIndexPath and it never gets printed. The cell does not even turn blue or look selected.

I changed the cells from my custom ones to regular UITableViewCells and I still can't select cells.

Upvotes: 8

Views: 8135

Answers (2)

jimmy
jimmy

Reputation: 137

I know this question has been posted long time ago but here is my answer for whom still stuck with this one:

   tableView.allowsSelectionDuringEditing = YES;

Upvotes: 3

Matt Williamson
Matt Williamson

Reputation: 40193

Try:

- (void)tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tv deselectRowAtIndexPath:indexPath animated:YES];
}

Upvotes: 4

Related Questions