Brosef Brosef - 1 year ago 66
iOS Question

UITableViewController cell remains highlighted when segueing back

I have a

and when a cell is selected, my app segues to a new view controller. When I press the back button in my navigation controller to go back to the previous tableview controller, the cell that I had selected remains highlighted. I checked
and it is true. Any idea why this is happening?

Answer Source

Are you calling the segue from didSelectRowAtIndexPath if so try something like this

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    performSegueWithIdentifier("Your Segue", sender: indexPath)
    tableView.deselectRowAtIndexPath(indexPath, animated: true)

You could also place tableView.deselectRowAtIndexPath the in the prepareForSegue method which is what I tend to do

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download