How to make a UIViewController the root of a NavigationController stack?
I'm currently pushing my main UIViewController from appDelegate with this code:
HomeViewController *homeViewController = [[HomeViewController alloc] init];
[self.navigationController pushViewContro开发者_运维技巧ller:homeViewController animated:YES];
//self.navigationController.view = homeViewController.view;
[homeViewController release];
However, I want it to be the root of the UINavigationController controllers stack, while it is currently possible to move back to another root view controller. Thanks
You can use this method:
- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
For example:
HomeViewController *homeViewController = [[HomeViewController alloc] init];
[self.navigationController setViewControllers:[NSArray arrayWithObject:homeViewController] animated:YES];
[homeViewController release];
精彩评论