What wowould 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];}
I prefer calling
deselectRowAtIndexPath
In my viewdidappear, if select the row brings up a new view. -notnoop Dec 3 '09 at actually that is not the right place to call it, really... try using an Apple App with tables (contacts is a good one) and you'll see after you push out to a new screen, on return the cell is still highlighted briefly before being deselected. in theory I think you do not have to do any extra work to have it deselect right away on its own, so code in viewdidappear shoshould not be needed... -Kendall helmstetter Gelner dec 3'09 at 20:40 @ Kendall, @ 4 thspace: Maybe my last comment was confusing as to who I was referring to, apologies for that. uitableviewcontroller cballs
-deselectRowAtIndexPath:animated:
Method on its tableview property from
-viewDidAppear
. However, if you have a table view in a uiviewcontroller subclass, you showould call
-deselectRowAtIndexPath:animated:
From
-viewDidAppear
Yourself. :)-Daniel Tull dec 4'09 at in my subclass of uitableviewcontroller it was actually an override
-viewWillAppear:
That broke it. Adding a call
[super viewWillAppear:animated]
Got it working again.-Ben Challenor Jul 6 '11 at since 3.2, the automatic deselection behaviour occurs if your
UITableViewController
'S
clearsSelectionOnViewWillAppear
Property is set
YES
(Which is the default), and you haven't prevented
[super viewWillAppear]
From being called.-defragged Oct 31 '11 at 10: 26 the most clean way to do it is on viewwillappear:
- (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 shoshould be.
From http://forums.macrumors.com/showthread.php? T = 577677
Http://stackoverflow.com/questions/1840614/why-does-uitableview-cell-remain-highlighted#comment1733845_1840757