2011-10-03 93 views
0

我想一個新的視圖控制器推到我彈出後,才導航堆棧堆棧RootViewController的如何推視圖控制器到導航堆棧後,在執行popToRootViewController

//Select the tab I want to go to 
self.tabBarController.selectedIndex = FEEDPAGE_INDEX; 

//Retrieve the navcon in the feed page 
UINavigationController *navcon = (UINavigationController*)[self.tabBarController.viewControllers objectAtIndex:FEEDTAB_INDEX]; 

//Pop to root view controller here 
[navcon popToRootViewControllerAnimated:YES]; 

//Push a new root view controller onto stack 
QuestionAnswerViewController *x = [[QuestionAnswerViewController alloc]init]; 
[navcon pushViewController:x animated:YES]; 

推送沒有工作即沒有顯示新的頁面。似乎popToRootViewController會導致這種情況發生(不確定)。任何建議如何可以彈出,然後推新頁面?

回答

2
QuestionAnswerViewController *x = [[QuestionAnswerViewController alloc]init]; 
UINavigationController *navcon = (UINavigationController*)[self.tabBarController.viewControllers objectAtIndex:FEEDTAB_INDEX]; 
NSArray *arr = [navcon viewControllers]; 
NSArray *newStack = [NSArray arrayWithObjects:[arr objectAtIndex:0], x, nil]; 
[navcon setViewControllers:newStack]; 
+0

這適用於我。謝謝! – Zhen

相關問題