Post

Replies

Boosts

Views

Activity

Reply to NavigationLink stays highlighted after returning from Detail View
Yes, I have the same problem in some lists in my app. Rows stay highlighted after navigating back. I have created a really easy solution to remove the highlight color in these situations. I use NotificationCenter to notify when the NavigationLink is tapped and use some UIKit-magic to deselect the cells. Works like a charm. All you need to do is add this block of code. Note that if your list has multiple sections, you have to modify the code. .onReceive(NotificationCenter.default.publisher(for: UITableView.selectionDidChangeNotification)) { notification in             if let tableView = notification.object as? UITableView {                 let numberOfRows = tableView.numberOfRows(inSection: 0)                 guard numberOfRows 0 else { return }                 for i in 0...rows - 1 {                     tableView.deselectRow(at: IndexPath(row: i, section: 0), animated: true)                 }             }         }
Mar ’21