开发者

How to make a UIViewController the root of a NavigationController stack?

开发者 https://www.devze.com 2023-04-01 19:07 出处:网络
I\'m currently pushing my main UIViewController from appDelegate with this code: HomeViewController *homeViewController = [[HomeViewController alloc] init];

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消