2011-09-07 73 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:动画。我可能不完美,但我有同样的问题,但现在我的应用程序按我的需要工作。

相关问题