Find out when a view controller is popped

I need to tell the phone when a child view controller is pushed or popped. When contextForSegue is called, I tell the phone that the child has been pushed. I haven't figured out a reliable way to tell when the child has been popped.


If I try to detect this in the willDisappear or didDeactivate of the child view controller, it may be called e.g. when the screen turns off, which is not what I want. If I do it in the willActivate or didAppear of the parent view controller, it may be called (surprisingly) e.g. when a complication activates even though the app is not visible at all.


I could also call it when the back button of the child view is pressed, but I don't think I have a way to get an event for that.


What would be the correct, reliable way to know that the child view controller has been popped for sure, and the user has actually seen the parent view controller?

Find out when a view controller is popped
 
 
Q