views:

333

answers:

3

I am new to iphone development.I created a table displaying my contents.If i select a row ,it state is highlighted in blue color and navigates to another view and if i click the back button it navigates back to the table showing the clicked cell in blue color,i want to remove the highlighted color on table while navigating back to its view.How can i do that. Thanks.

A: 

The default implementation of viewDidAppear: should take care of that for you. If you did override that method in your table view controller, don't forget to call [super viewDidAppear:animated] in your override method.

Frank Schmitt
A: 

I finally got it by implementing this in my table view class.

- (void)viewWillAppear:(BOOL)animated  
{  
    NSIndexPath *tableSelection = [self.tableView indexPathForSelectedRow];  
    [self.tableView deselectRowAtIndexPath:tableSelection animated:NO];  
}  
Warrior
A: 

I think the generally accepted way to do this is to deselect the cell as you're navigating to the new view. Instead of viewWillAppear, use the tableview delegate method didSelectRowAtIndexPath and the same deselectRowAtIndexPath you were using.

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

(and by generally accepted, I mean "stuff I most often see in example code". It depends on what you want it to look like in the end)

Nick