這裏的一個示例代碼,用於創建與兩個控制器一個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];