UITableView does not automatically deselect the selected row when the table re-appears

Normally a selected row in a UITableView gets deselected with an animation when the user pops back from the detail view.

However, in my case where I have a UITableView embedded in a UIViewController I have to do it manually in viewWillAppear like so:

    [super viewWillAppear:animated];
    // For some reason the tableview does not do it automatically
    [self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow 

Why is this and how to fix it?


When your main ViewController is from type UITableViewController, it has a property clearsSelectionOnViewWillAppear, which is per default YES - so it will clear the selection automatically.

This property is not available for an UITableView, i guess it's because it has no ViewWillAppear method either.

A UIViewController doesn't need this property because it has no UITableView originally.

conclusion: you'll have to implement it by yourself when you do not use a UITableViewController.

Need Your Help

JDBC PreparedStatement with “?” in the Column Name

java ms-access jdbc prepared-statement

I am using a JDBC connection to fetch data from the Ns Access Database.

Library, control for C# that represents table in Form

c# visual-studio-2010 table controls spreadsheet

I need to put a table (like spreadsheet but without formulas, only numbers) at Form. It would be nice if it had adjustable size. Do you know any control like this?