Richard McCluskey
Richard McCluskey

Reputation: 588

Conditional Navigation Controller Root

I have a tab bar controller into a navigation controller. I want to change the navigation controller's root view depending on whether or not a user is logged in. How do I do this? I don't want to put the code in didFinishLaunchingWithOptions: or any other AppDelegate method because it won't be the first thing the users will see.

Upvotes: 1

Views: 523

Answers (1)

ddevaz
ddevaz

Reputation: 2263

You're right, its supposed to be:

- (void) goNext {
NextViewController* nextWindow = [[NextViewController alloc] initWithNibName:@"NextView" bundle:nil];
[self.navigationController setViewControllers:[NSArray arrayWithObject:nextWindow] animated:YES];
}

Since you can't pop the root view controller, the following method can be used instead:

- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated

Here's a link to the apple docs for this method.

Upvotes: 1

Related Questions