Brosef Brosef - 4 months ago 5
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?


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