I want to do some saving stuff when the user hits the back button on a navigation controller. Is this only possible by implementing
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
int index = [[self.navigationController.viewControllers] indexOfObject:[self.navigationController.visibleViewController]];
if(viewController == [[self.navigationController.viewControllers] objectAtIndex:index-1])
//saving code here
so the delegate gets called when it's about to show the previous view controller. Is there a more elegant way of knowing when the view controller will be popped?
and I can't use viewWillDisappear because there's a button that displays a UIImagePickerController, and I don't want the saving to be done then. Any thoughts?