Skip to content

Instantly share code, notes, and snippets.

@remear
Created March 26, 2012 16:33
Show Gist options
  • Save remear/2206360 to your computer and use it in GitHub Desktop.
Save remear/2206360 to your computer and use it in GitHub Desktop.
How viewWillDisappear
- (void)viewWillDisappear:(BOOL)animated {
NSArray *viewControllers = self.navigationController.viewControllers;
if (viewControllers.count > 1 && [viewControllers objectAtIndex:viewControllers.count-2] == self) {
// View is disappearing because a new view controller was pushed onto the stack
NSLog(@"New view controller was pushed");
} else if ([viewControllers indexOfObject:self] == NSNotFound) {
// View is disappearing because it was popped from the stack
NSLog(@"View controller was popped");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment