2011-09-07 82 views
0

如何將UINavigationController添加到xCode選項卡欄應用程序委託?將UINavigationController添加到xCode選項卡欄應用程序模板

我的結構是基於xCode標籤欄應用程序委託,分別有2個選項卡,第一視圖&第二視圖。對於第一視圖,我添加了一個UITableView。我只是想利用UINavigationController函數[self.navigationController pushViewController:animated:]推送一個子視圖,並允許在子視圖中顯示導航欄。推動子視圖後,標籤欄仍然在那裏。

聽起來很簡單,但我不知道如何實現它。請幫忙。

回答

1

我開始使用基於Window的模板,而這樣做是爲了達到同樣的目的。

我在我的應用程序委託中手動創建了我的NavigationControllersTabBarController

在你:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 

補充一點:

//Seeting up the Navigation controllers and pushing our TableView controllers. 
UINavigationController *unvc1 = [[UINavigationController alloc] init]; 
UINavigationController *unvc2 = [[UINavigationController alloc] init]; 
[unvc1 pushViewController:someViewController1 animated:NO]; 
[unvc2 pushViewController:someViewController2 animated:NO]; 
[someViewController1 release];[someViewController2 release];//Releasing our TableView controllers. 

//Setting up the TabBar controller and pushing our Navigation controllers. 
UITabBarController *tbvc = [[UITabBarController alloc] init]; 
tbvc.viewControllers = [NSArray arrayWithObjects:unvc1, unvc2, nil]; 
[unvc1 release];[unvc2 release]; //releasing our Navigation controllers. 

我希望這有助於。

+0

是否有Interface Builder解決方案? – Raptor

+0

當然,但不幸的是我沒有與該模板一起工作,所以我就這樣設置它。我知道這不是你想要的,但它會幫助你前進。此外,任何'ViewController'被推入到'NavigationController'中,因此''TabBarConrtoller',可以用IB創建。 – rjgonzo

1

我用presentModalViewController做了這個:動畫。我在modalView中添加了tabBar控制器。在方法didSelectRowAtIndexPath使用thisModalViewController:動畫。我可能不完美,但我有同樣的問題,但現在我的應用程序按我的需要工作。

相關問題