我已經創建了一個標籤式應用程序,每個標籤有4個標籤和4個viewController。我嘗試在FirstViewController中添加導航欄,它只添加導航欄,內容區域顯示爲黑色。結合標籤,導航控制器和視圖控制器
- 如何組合導航控制器,選項卡和視圖控制器?
- 什麼是組合ViewControllers的可能方式?
我Tab和視圖控制器代碼:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1, *viewController2,*viewController3, *viewController4;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
viewController1 = [[VKFirstViewController alloc] initWithNibName:@"VKFirstViewController_iPhone" bundle:nil];
viewController2 = [[VKSecondViewController alloc] initWithNibName:@"VKSecondViewController_iPhone" bundle:nil];
viewController3 = [[VKThirdViewController alloc] initWithNibName:@"VKThirdViewController_iPhone" bundle:nil];
viewController4 = [[VKFourthViewController alloc] initWithNibName:@"VKFourthViewController_iPhone" bundle:nil];
} else {
viewController1 = [[VKFirstViewController alloc] initWithNibName:@"VKFirstViewController_iPad" bundle:nil];
viewController2 = [[VKSecondViewController alloc] initWithNibName:@"VKSecondViewController_iPad" bundle:nil];
viewController3 = [[VKThirdViewController alloc] initWithNibName:@"VKThirdViewController_iPad" bundle:nil];
viewController4 = [[VKFourthViewController alloc] initWithNibName:@"VKFourthViewController_iPad" bundle:nil];
}
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[viewController1, viewController2,viewController3, viewController4];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
我加viewController1一個navigationController內,這navigationController對象添加到tabBarController。現在它工作正常。請參閱http://stackoverflow.com/questions/14015122/combining-navigation-controller-with-tab-bar-controller – Ramprasad 2013-05-09 07:08:25