Don't put the popToRoot in the viewWillDisappear
method. I assume that you have some function that gets called when the user is all done with the registration process in Controller C. At the end of that method you need to put [self.navigationController popToRootViewControllerAnimated:YES]
Putting it in viewWillDisappear
and especially before the [super viewWillDissappear]
method is most likely causing the problem.
EDIT:
Try structuring your viewWillDisappear method like this, with the super call first:
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController popToRootViewControllerAnimated:YES];
}
EDIT:
Well, I have got it to kind of work. If you don't need to push anymore views onto it after you have popped from Controller C this will work. Update the -viewWillDisappear in Controller C to look like this:
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController setViewControllers:@[[self.navigationController.viewControllers objectAtIndex:0]] animated:YES];
}