0

I have a strange problem. I found some tipps here and in the internet but I nothing solved my problem. So here is what happens:

I have a TabBar Navigation with 9 items. All of them are UINavigationItems. On one of them I replace the default viewController with another one under certain conditions.

To do that, I use popViewController and pushViewController. This works perfectly but I have the problem, that the UINavigationBar is not in sync with that. That has the effect that I see the correct view but the when I click on the "back" button it shift's to an empty navbar item and from there I come back to the rootViewController ("more" for example).

Here is my code:


- (void)viewWillAppear:(BOOL)animated { 
  if ([[myAppDelegate bcUser] userLoggedIn]) {
    // user is logged in
    MyDataLoggedInViewController *loggedInViewController = [[[MyDataLoggedInViewController alloc] initWithNibName:@"MyDataLoggedInView" bundle:nil] autorelease];
    UINavigationController *navController = self.navigationController;
    [[self retain] autorelease];

    [navController popViewControllerAnimated:YES];
    [navController pushViewController:loggedInViewController animated:YES];
  } 
}

I hope someone can help. I tried everything I found and nothing helped. :-/

Thanks and best wishes, Thomas

thomas
  • 1,446
  • 8
  • 20

1 Answers1

0

Try setting:

[navController popViewControllerAnimated:NO];
[navController pushViewController:loggedInViewController animated:NO];

because you're most likely waiting for animations to complete.

Brirony
  • 31
  • 2
  • Either that or you need to reset the rootView of your UINavigationController. – Brirony Mar 04 '11 at 01:18
  • Unfortunately this doesn't help. I already tried it with no luck. What does "reset the rootView" mean? – thomas Mar 04 '11 at 05:53
  • [UINavigationController class Reference](http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html) the rootView of the navigationController is the viewController that rests at position 0 (the bottom) of your navigation stack. – Brirony Mar 04 '11 at 17:53