Swift - How to get notified after removeFromSuperview() has been called?

Viewed 1721

I have two view controllers. The firstVC is being loaded when the app launches, then if a certain button was tapped then secondVC is being called using this code:

    let popOverVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "tagsStory") as! TagsVC
    self.addChildViewController(popOverVC)
    popOverVC.view.frame = self.view.frame
    self.view.addSubview(popOverVC.view)
    popOverVC.didMove(toParentViewController: self)

In the secondV when a certain button is tapped the secondVC gets removed and firstVC gets back to the user via this code:

self.view.removeFromSuperview()

My question is, how do I get notified when the secondVC has been removed inside the firstVC?

I tried to use, viewDidAppear, viewWillAppear, willMove... but nothing worked yet.

3 Answers
Related