0

I'm beginner for iOS dev. In my app, RootView jump to son views: A、B、C、D through buttons (defined in storyboard, push segue). i use some image to be touched so the son views can push to each other, I.E the code in B Controller:

// jump to View C
[self.navigationController pushViewController:CView animated: YES];

the code in C Controller, define backButton clicked to show RootView:

-(void) viewWillDisappear:(BOOL)animated {
    if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
        [self.navigationController popToRootViewControllerAnimated:NO];
    }
    [super viewWillDisappear:animated];
}

It's perfect to show RootView, but the top shows backButton and title which i defined in B Controller. RootView have an image title. Other view's title was set in storyboard. What can i do now?

1 Answers1

0

solved, the navigationBar also need to be poped:

-(void) viewWillDisappear:(BOOL)animated {
    if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
        // add this pop:
        [self.navigationController.navigationBar popNavigationItemAnimated:NO];
        [self.navigationController popToRootViewControllerAnimated:NO];
    }
    [super viewWillDisappear:animated];
}