I am having problem with my table view cell. I can't disable the highlight of table cell selection after returning from detail view to main table view using segue with embedded navigation controller. The table cell is still selected. I don't want the table cell selection to be disable when I click one of them to show the detail. I only want to disable them after I returning back from detail view.
I got it now. I solved like this. It's simple theory.
We just deselect it when we select the row
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
}
The way I like to do it, if you have single selection enabled is to use the viewDidAppear Method. That way the user can see the deselection animation when he returns to the tableView.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
if let selectedRow = tableView.indexPathForSelectedRow {
tableView.deselectRow(at: selectedRow, 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