I have an existing iphone app whihc has nav controller as its root controller. Now i have to add a tab bar controller at the bottom of the screen. how can i achieve this change?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
first you need to create tab bar controller in the root , then you put navigation controller or other view controller for each tab bar
good luck
回答2:
Are you having more than one viewControllers to be shown in the tab? Add the viewControllers to tabBar's viewControllers. USe this property
tabBarController.viewControllers = view_Controllers_Array;
eg.
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];