I currently need to implement some code when the top view controller is being popped off from my navigation controller. Is there a way to detect when the view controller is being popped off the navigation controller stack?
As much as possible I want to stay away from using viewWillDisappear
or viewDidDisappear
because I'm using a splitview
in my project, and selecting a different row in the master view will also trigger the viewWillDisappear
/viewDidDisappear
methods.
Best Answer
You can detect whether a view is being popped using the
isMovingFromParentViewController
property for a view controller as shown below: