Deselecting the table view row when returning Deselecting the table view row when returning ios ios

Deselecting the table view row when returning


why you just don't deselect it in the delegate method

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];}


If you are using a NavigationController, you can do it with its delegate:

- (void)navigationController: (UINavigationController *)navigationController       didShowViewController: (UIViewController *)viewController                    animated: (BOOL)animated{    [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];}

But you have to check whether the show controller is which you want =/

[EDIT]Create the outlet and link it in IB to NavigationController

@interface MyInt <UINavigationControllerDelegate>{    IBOutlet UINavigationController *navigation;    ...}@property (nonatomic, retain) UINavigationController *navigation;...@end@implementation MyInt@syntesize navigation;- (void)viewDidLoad{    [super viewDidLoad];    [self.navigation setDelegate: self];}...@end


Are you selecting the row programmatically? If so, I had the same problem when selecting a row using [cellToBeSelected setSelected:YES];.

By using the UITableViewController's selectRowAtIndexPath:animated:scrollPosition: method it kept track of the current selected indexPath.

In fact, if clearsSelectionOnViewWillAppear is set to true, one does not have deselect rows manually.


matomo