Adding a second answer with an example of how to do this using UINavigationControllerDelegate.
Somewhere, set the delegate to the root controller. Either with the code, or by connecting it to the tip. Make your root controller a UINavigationControllerDelegate .
@interface MyViewController : UIViewController <UINavigationControllerDelegate> // ... @end
Do this in the root view controller implementation
@implementation MyViewController - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { [viewController performSelector:@selector(willBeShownViaNavigationController)]; [navigationController.visibleViewController performSelector:@selector(willBeHiddenViaNavigationController)]; } @end
Ensure that all view controllers used in this navigation controller implement these two methods.
Note: this code has not been verified, there may be some errors. But you should get this idea.
source share