使用界面生成器或編碼在每個選項卡中顯示,創建您的UIViewControllers和那裏的視圖。將NavigationBar添加到這些視圖中的每一個。
然後將這些UIViewControllers添加到UITabViewController的viewControllers NSArray。
即。在你的AppDelegate的應用didFinishLaunching功能
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
的UINavigationBar的添加到viewController1和viewControllers2意見,或者使用IB或編碼它。
非常感謝Wextux的快速回復。我嘗試過你的技術,但它對我沒有任何作用。抱歉。 – NightFury