How to be alerted when uiviewcontroller is pushed / popped from navigation stack

You can try UINavigationController delegate methods it calls when object push or pop from navigation controller stack.

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated;

Here's an example to detect when a view controller is being pushed onto the navigation stack by overriding -viewWillAppear: and popped by overriding -viewWillDisappear:

-(void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
    if (self.isMovingToParentViewController) {
        NSLog(@"view controller being pushed");        
    }
}

-(void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
    if (self.isMovingFromParentViewController) {
        NSLog(@"view controller being popped");
    }
}

To find out when it's pushed, you can use the

UINavigationControllerDelegate

and implement

- (void)navigationController:(UINavigationController *)navigationController 
      willShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated

This method will fire whenever the viewcontroller is pushed into the navigation stack, and whenever the viewcontroller on top of it is popped off, thus revealing it again. So you have to use a flag to figure out if it's been initialized yet, if it hasn't means it just was pushed.

To find out when it's been popped, use this answer:

viewWillDisappear: Determine whether view controller is being popped or is showing a sub-view controller