我用了一個新的基於窗口的應用程序,並把下面的代碼:
的想法是創建一個的UITabBarController並把它NavigationController代替ViewControllers的。
並且每個navigationController將導航到它自己的一組ViewContrllers。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UITabBarController* tabBarContoller = [[UITabBarController alloc]init];
Cross1VC* cross1VC = [[Cross1VC alloc]initWithNibName:@"Cross1VC" bundle:nil];
cross1VC.title = @"Cross 1";
UINavigationController* crossNav = [[UINavigationController alloc]initWithRootViewController:cross1VC];
crossNav.title = @"Cross";
[cross1VC release];
Part1VC* part1VC = [[Part1VC alloc]initWithNibName:@"Part1VC" bundle:nil];
part1VC.title = @"Part 1";
UINavigationController* partNav = [[UINavigationController alloc]initWithRootViewController:part1VC];
partNav.title = @"Part";
[part1VC release];
NSArray* viewControllers = [NSArray arrayWithObjects:crossNav, partNav, nil];
[tabBarContoller setViewControllers:viewControllers animated:YES];
//tabBarContoller.delegate = [[SomeDelegateHandlerClass alloc]init]; // assign, not retain
[self.window addSubview:tabBarContoller.view];
//[tabBarContoller release]; // make instance variable and release in dealloc
[self.window makeKeyAndVisible];
return YES;
}