4

When I click a cell it selects, but it stays blue on touch up. I want the blue highlight to leave on touch up (but it's important that it highlights in the first place).

This last answer in this post mentions something about willSelectRowAtIndexPath:, but I can't figure out how to use that to do what I want. Also, I do need didSelectRowAtIndexPath: to still be called, I just want the cell to unhighlight on touch-up.

Community
  • 1
  • 1
JoshDG
  • 3,871
  • 10
  • 51
  • 85

1 Answers1

6

Use the following where appropriate:

[tableView deselectRowAtIndexPath:indexPath animated:YES];

e.g. in didSelectRowAtIndexPath:

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

This will deselect the row at the specified index path.

You could also be interested in clearsSelectionOnViewWillAppear property in UITableViewController. If this property is set to yes then the controller clears the selection when the table appears. In default it set to YES.

Reference.

Hima
  • 1,249
  • 1
  • 14
  • 18
Ondrej Peterka
  • 3,349
  • 4
  • 35
  • 49