views:

185

answers:

2

I have a cell with a few lines of text which changes colour when selected/highlighted. The problem is that as the new viewController is being pushed, the deselection animation occurs which is visually distracting as the text suddenly reverts to the unselected state. I have moved the deselectRowAtIndexPath statement after the line where the new view controller is pushed, but this has no effect.

How can I prevent the user seeing the cell deselection (without implementing a timer)? Any help would be appreciated please.

+2  A: 

I think the general paradigm used with table views and pushing new VCs is that you deselect the table row in your viewWillAppear:animated method. Then as the VC is popped, they see which row had been used to navigate to that VC.

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    [self.myTableView deselectRowAtIndexPath:[myTableView indexPathForSelectedRow] animated:YES];

}

so remove deselectRow from your didSelectRowAtIndexPath method.

wkw
Thanks, that makes sense. However, my viewWillAppear method is not firing?
Run Loop
Update: viewWillAppear is not firing as I am using a navigation controller, so I have implemented - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
Run Loop
+3  A: 

If you're using a UITableViewController, you won't need to call deselectRowAtIndexPath:. This will be done for you automatically when your table view becomes visible again.

If you're not using a UITableViewController because you have a more complicated interface, you would need to call deselectRowAtIndexPath: manually from the viewWillAppear:animated: method.

Alex
That's interesting, didn't know that bit of trivia.
wkw
I am using a tableViewController, but the row is not automatically deselected when the pushed vc is popped
Run Loop
You subclassed UITableViewController? If so, are you calling `[super viewWillAppear]`? If you read the Overview section for UITAbleViewController, I see it does discuss the various behaviors the UITAbleViewController base class provides.
wkw