I have a uitableview cell highlighted when a user selects it and then is pushed to a detail view. I would like the cell to be unhighlighted when they return to the table view view controller.
how would I go about accomplishing this?
I'm guessing [cell.textLabel setHighlighted:NO];
in viewWillAppear, but cell is undeclared if I put it there.
thanks for any help
If you using UITableViewController
subclass then just set property
self.clearsSelectionOnViewWillAppear = YES;
else in viewWillAppear
just call
NSIndexPath *indexPath = self.tableView.indexPathForSelectedRow; if (indexPath) { [self.tableView deselectRowAtIndexPath:indexPath animated:animated]; } // MARK: - Swift 3 if let indexPath = tableView.indexPathForSelectedRow { tableView.deselectRow(at: indexPath, animated: true) }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With