这里的一个示例代码,用于创建与两个控制器一个tabBarController作为选项卡:
myTabBarController = [[UITabBarController alloc] init];
NewsFeedController * newsFeedController = [[NewsFeedController alloc] initWithFacebook:facebook];
UINavigationController * navigationControllerHome = [[UINavigationController alloc] initWithRootViewController:newsFeedController];
[newsFeedController release];
AboutController * aboutController = [[AboutController alloc] init];
UINavigationController * navigationControllerAbout = [[UINavigationController alloc] initWithRootViewController:aboutController];
[aboutController release];
myTabBarController.viewControllers = [NSArray arrayWithObjects:navigationControllerHome, navigationControllerAbout, nil];
[self.window addSubview:myTabBarController.view];