再会。我尝试将带有导航控制器的新选项卡添加到我的应用程序中。我创建了一个新的选项卡式应用程序(xcode 4.2)并在 appdelegate 中写了这个
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];
UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];
NavController *navController = [[[NavController alloc] initWithNibName:@"NavController" bundle:nil] autorelease]; //my controller
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, navController, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
导航控制器.h 文件
@interface NavController : UINavigationController
@end
这里是项目的结构
当我运行项目时,它显示空选项卡 但在 xib 文件中我添加标签和按钮 可能是我忘记了什么?