我创建了一个选项卡式应用程序,每个选项卡有 4 个选项卡和 4 个视图控制器。我尝试在 FirstViewController 中添加导航栏,它只添加导航栏,内容区域显示为黑色。
- 如何组合导航控制器、选项卡和视图控制器?
- 组合 ViewController 的可能方式有哪些?
我的选项卡和视图控制器代码:
- (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;
}