NEW: Subscribe to Hacking with Swift+ and accelerate your learning! >>

tableView didSelectRowAt leads to previous chosen viewController

Forums > iOS

@beco0  

Hello, I'm on Project 7 of 100 days of Swift and got problem with tableviewcontroller - when i click on the row, it becomes darker but nothing happen, then when i click on any other row, the second one becomes darker and navigationController pushes detailViewController with view connected to the first row i chosed - in this case, it shows petition from 1st chosen row. I think it could be connected to some default xcode settings. What should I change in XCode settings or add to my code?

   

Post your didSelectRowAt method ...

   

@beco0  

Ok, sorry, here it is.


    override func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
        let vc = DetailViewController()
        vc.detailItem = petitions[indexPath.row]
        navigationController?.pushViewController(vc, animated: true)
    }

   

The petition is class or struct? Can you post methods for numberOfRows and cellForRowAt?

   

Hacking with Swift is sponsored by NSSpain

SPONSORED Announcing NSSpain 2020: Remote Edition! An online, continuous conference for iOS developers. We’ll start on Thursday and finish on Friday, with talks, activities, and lots of fun for 36 hours, non-stop. Sound good? Join us!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

Not logged in

Log in
 

Link copied to your pasteboard.