In my application, when the user presses the back button on the navigation bar, I want the program to trigger some action. Therefore, I had been using willMoveToParentViewController. However, the method gets called when the viewController is added or removed. What is the way to prevent it from being called when the viewController is added? If there was an alternate way to detect when the backButton in the navigationBar was pressed, please suggest it.
Thanks!
Use
viewDidDisappearfor the same. You can check the apple documentation here. This notifies the view controller when its view is removed from a view hierarchy.