2009-01-23 64 views
2

我正在構建一個具有TabBarController的應用程序,並且每個選項卡視圖都有導航視圖控制器。當用戶點擊標籤時,我想讓relavent導航視圖控制器「重置」到根面板。在TabBarController + NavigationController mix env中,如何在選項卡更改時重置導航?

在我的代碼中,我使用下面的方式來初始化選項卡和導航控制器。

viewController1 = [[MyFirstController alloc] init];    
UINavigationController *tableNavController = [[[UINavigationController alloc] initWithRootViewController:viewController1] autorelease]; 

viewController2 = [[MySecondController alloc] init]; 
UINavigationController *table2NavController = [[[UINavigationController alloc] initWithRootViewController:viewController2] autorelease]; 


tabBarController.viewControllers = [NSArray arrayWithObjects:tableNavController, table2NavController, nil]; 

    Then appears that all the tab and navigation controller is working automatically. I am not sure where to cut in to let navigation controller view to reset when it is selected. 

謝謝。

回答

1

導航控制器是由系統發送的消息viewWillAppear中,這樣你就可以實現做復位的方法.. 另一種選擇是使用標籤欄控制器的selectedViewController方法來檢索選定的導航控制器.. 希望有所幫助..

相關問題