美好的一天。我嘗試添加新的導航控制器選項卡到我的應用程序。我創建了一個新的選項卡式應用程序(的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;
}
NavController.h文件
@interface NavController : UINavigationController
@end
以下項目
的結構,當我運行它的項目給我看空標籤 但是在xib文件中我加了標籤和按鈕 可能是我忘記了什麼?
試圖在委託中添加這個UINavigationController * localNavigationController; NavController * navController = [[[NavController alloc] initWithNibName:@「NavController」bundle:nil] autorelease]; localNavigationController = [[UINavigationController alloc] initWithRootViewController:navController];但它在initWithRootControllerMethod中崩潰 – nabiullinas