As the answers above point out, you need to explicitly deselect the row. You have two options as to how you do this. The first, is to deselect the row immediately after selection:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
...
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
That will work just fine, but there is an alternative, and its the approach taken by UITableViewController
which is to leave the row selected then deselect it when the view re-appears (after the controller you're pushing is popped off of the stack).
This has the slight advantage that the user sees a glimpse of their previous selection when they return so they can see what they had selected previously.
To implement this, you just need to override viewDidAppear
:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
}
As I said, this is what the default of implementation of UITableViewController
's viewDidAppear:
does so if you are using UITableViewController
and not seeing this behaviour, you should check that you are calling the super
implementation in your class' own viewDidAppear:
.