Search code examples
objective-cnavigationuinavigationcontrollerstoryboard

Objective C: Navigation title is overridden


I have 3 storyBoards, A, B and C. A has a TabBarController.

When I move from A to B I make it like the code bellow:

BViewController* vcB = (BViewController*) [R2Utils getViewControllerWithId:@"BViewController" fromStoryBoard:StoryboardB];
    [self.navigationController presentViewController animated:YES];

where vcB is the NavigationController in the storyboard B.

when navigating from B to C:

UINavigationController* nav = (UINavigationController*)  [R2Utils getViewControllerWithId:@"MainAppNavigationController" fromStoryBoard:StoryboardC];

[UIView transitionFromView:self.window.rootViewController.view
                                toView:nav.view
                              duration:0.8f
                               options:UIViewAnimationOptionTransitionFlipFromRight
                            completion:^(BOOL finished){
                                self.window.rootViewController = nav;
                            }];

The problem is that the title of the navigation bar is being overridden by a navigation bar of previous Controller(check the image). enter image description here


Solution

  • Simply the problem was: The previous controllers from storyboard B are still in the heterarchy. The navigationController in storyboard C has a backgoroundColor = [UIColor clearColor]. So in storyBoard C, we can see the title of the current controller and the content of the navigationController bar in storyBoard B