如何在现有的iphone应用程序中用标签栏控制器替换导航根控制器

时间:2011-03-04 05:26:38

标签: iphone uinavigationcontroller uitabbar

我有一个现有的iphone应用程序,它有一个导航控制器作为其根控制器。现在我必须在屏幕底部添加一个标签栏控制器。我怎样才能实现这一变化?

2 个答案:

答案 0 :(得分:1)

首先你需要在根目录中创建标签栏控制器,然后为每个标签栏放置导航控制器或其他视图控制器

祝你好运

答案 1 :(得分:1)

您是否要在标签中显示多个viewControllers?  将viewControllers添加到tabBar的viewControllers。使用此属性

tabBarController.viewControllers = view_Controllers_Array;

例如

NSMutableArray * viewControllers = [[NSMutableArray alloc]init];


FirstViewController * firstViewController = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil];
UINavigationController * nvc = [[UINavigationController alloc] initWithRootViewController:firstViewController];
[firstViewController release];
[viewControllers addObject:nvc];
[nvc release];

SecondViewController * secondViewController = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
 nvc = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[secondViewController release];
[viewControllers addObject:nvc];
[nvc release];

UITabBarController * tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = viewControllers;
[window addSubview:tabBarController.view];