-1

I have a view controller with a UIScrollView, UIButtons, UILabels, and UIViews. When I visit the same view controller a second time with for example a different label text value, I can still see the objects as they were before when I visited the view controller for the first time. This is the code I use to pop the view controller:

navigationController?.popViewController(animated: true)
dismiss(animated: true, completion: nil)
Lamour
  • 3,002
  • 2
  • 16
  • 28
Brandon Cornelio
  • 333
  • 3
  • 14
  • "When I visit the same view controller a second time" - do you push a new VC in the navigation controller? And after poping the VC , check the navigation stack whether the VC is still there or not. – Vizllx Sep 26 '17 at 03:35
  • I'll check the navigation stack now. I use a push segue to get to the aforementioned page, pop it, then use that segue again to go back and the contents of the initial visit are still on there. Hope that clarifies my situation – Brandon Cornelio Sep 26 '17 at 03:43
  • The view controller is not in the navigation stack when popped – Brandon Cornelio Sep 26 '17 at 03:48
  • https://stackoverflow.com/a/15839298/2714702 – Vizllx Sep 26 '17 at 03:53
  • Where/How are you pulling your data? – ZGski Sep 26 '17 at 03:56

1 Answers1

0

Sounds like your second view controller is not being deinit when popped.

Add the following code to your second view controller(only the deinit part) and see if it is called when you pop.

class MySecondViewController: UIViewController {
    deinit {
        print("Second view controller popped!")
    }

    override func viewDidLoad() { ... }
}

If it's not called, then you have some sort of strong references between view controllers.

sCha
  • 1,454
  • 1
  • 12
  • 22