2011-08-30 32 views
0

我目前正在推我的主要的UIViewController從使用的appDelegate這段代碼:如何使UIViewController成爲NavigationController堆棧的根?

HomeViewController *homeViewController = [[HomeViewController alloc] init]; 
[self.navigationController pushViewController:homeViewController animated:YES]; 
//self.navigationController.view = homeViewController.view; 
[homeViewController release]; 

不過,我希望它是UINavigationController的控制器堆棧的根,而這是目前可能搬回到另一根視圖控制器。 感謝

回答

0

您可以使用此方法:

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

例如:

HomeViewController *homeViewController = [[HomeViewController alloc] init]; 
[self.navigationController setViewControllers:[NSArray arrayWithObject:homeViewController] animated:YES]; 
[homeViewController release]; 
相關問題