What would cause a tableview cell to remain highlighted after being touched? I click the cell and can see it stays highlighted as a detail view is pushed. Once the detail view is popped, the cell is still highlighted.
#######
In your didSelectRowAtIndexPath you need to call deselectRowAtIndexPath to deselect the cell.
So whatever else you are doing in didSelectRowAtIndexPath you just have it call deselectRowAtIndexPath as well.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Do some stuff when the row is selected
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
deselectRowAtIndexPath
in my viewDidAppear, if select the row brings up a new view. – notnoop Dec 3 '09 at 15:59 -deselectRowAtIndexPath:animated:
method on its tableView property from -viewDidAppear
. However, if you have a table view in a UIViewController subclass, you should call -deselectRowAtIndexPath:animated:
from -viewDidAppear
yourself. :) – Daniel Tull Dec 4 '09 at 12:19 -viewWillAppear:
that broke it. Adding a call to [super viewWillAppear:animated]
got it working again. – Ben Challenor Jul 6 '11 at 9:38 UITableViewController
's clearsSelectionOnViewWillAppear
property is set to YES
(which is the default), and you haven't prevented [super viewWillAppear]
from being called. – Defragged Oct 31 '11 at 10:26 - (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// Unselect the selected row if any
NSIndexPath* selection = [self.tableView indexPathForSelectedRow];
if (selection) {
[self.tableView deselectRowAtIndexPath:selection animated:YES];
}
}
This way you have the animation of fading out the selection when you return to the controller, as it should be.
Taken from http://forums.macrumors.com/showthread.php?t=577677
http://*.com/questions/1840614/why-does-uitableview-cell-remain-highlighted#comment1733845_1840757