I have two ViewControllers, first and second. They are connected with show (push) segue. I click button on firstViewController to go to secondViewController. Then using automatically added navigation controller <First
, I go back to firstViewController. However, here I would like to get alert message when navigation controller to firstViewContoller is pressed. How do I do it?
You can work on the viewWillDisappear method on your second view controller like this:
- (void)viewWillDisappear:(BOOL)animated
{
if(self.isMovingFromParentViewController){
NSLog(@"Controller being popped");
}
}
In this case, self.isMovingFromParentViewController will be true if the controller is being popped.
You can also check for self.isMovingToParentViewController on viewWillAppear for example, to check that the controller is being pushed.
Also self.isBeingDismissed and self.isBeingPresented are available and refer to when a controller is being presented/dismissed (modally).