- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
FirstViewController *firstViewController=[[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil];
UINavigationController *navControl1=[[UINavigationController alloc]initWithRootViewController:firstViewController];
[firstViewController release];
SecondViewController *secondViewController=[[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
UINavigationController *navControl2=[[UINavigationController alloc]initWithRootViewController:secondViewController];
[secondViewController release];
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navControl1, navControl2, nil];
[navControl1 release];
[navControl2 release];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
如果某个tabBar不需要navigation,那么用如下代码初始化对应的control
UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];
本文介绍如何在iOS应用中设置带有导航控制器(Navigation Controller)的TabBar,并提供了一个不需要导航控制器的TabBar实现示例。
2321

被折叠的 条评论
为什么被折叠?



