1

this is my question. I have three View Controllers (VC1, VC2 and VC3). Every View Controller inherited from UINavigationControllerDelegate and I delegate my navigation controller into the viewWillAppear method in this way:

self.navigationController.delegate = self;

And the only UINavigationControllerDelegate method that I use is for transition:

- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                                  animationControllerForOperation:(UINavigationControllerOperation)operation
                                               fromViewController:(UIViewController *)fromVC
                                                 toViewController:(UIViewController *)toVC {
    if (operation == UINavigationControllerOperationPush || operation == UINavigationControllerOperationPop) {
        myTransitionController *transitionController = [[myTransitionController alloc] init];
        return transitionController;
    }else{
        return nil;
    }
}

My problem is this: when I walk from VC1 to VC2 and into this controller trigger a NSNotification, I execute popViewControllerAnimated to go back the previous View Controller (VC1). This is the code:

- (void) backToRoot: (id) sender{
    [self.navigationController popViewControllerAnimated:YES];
}

and the UINavigationBar show correctly its appearance (UINavigationBar without back button). Then, when I walk from VC1 to VC2 until VC3, and programatically go back until VC1 with popToRootViewController, the transition of the views (VC3-VC2-VC1) it works perfectly, but the UINavigationBar appearance not update and it shows with back button in the VC1 (which is the root View Controller). The method in the VC3 that I implemented is this:

- (void) goToRoot{
   [self.navigationController popToRootViewControllerAnimated:YES];
}

I have tried with a double call of popViewControllerAnimated, I added in viewWillAppear and viewDidAppear method into VC2 and It not works neither. Anyone have idea what happens?

1 Answers1

0

According to the documentation the func Pops all the view controllers on the stack except the root view controller and updates the display but I can't figure out the problem. You can try with unwind segue, is really simple.

What are Unwind segues for and how do you use them?

Community
  • 1
  • 1
Leandro P
  • 213
  • 4
  • 12