I'm relatively new to iOS development and I have an issue with popping view controllers. I need to pop two (or more) UIViewControllers
from the navigation stack when back button is pressed. Since I don't want them all to be animated I'm first popping all but last one un-animated and then last one animated, but then -viewWillDisappear
is not getting called only for that last one. Here's my code (these are getting called from super UIViewController
that all others are extended from):
//popping all but last one - viewWillDisappear getting called for these
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:j] animated:NO];
//popping last one - viewWillDisappear not getting called for this one
[self.navigationController popViewControllerAnimated:YES];
//also tried this but with same result:
//[((UIViewController*)[self.navigationController.viewControllers objectAtIndex:j]).navigationController popViewControllerAnimated:YES];
Does someone know what am I doing wrong here or can you instruct me how to correctly achieve what I need?