這在Xcode 3中非常容易。但是我完全在Xcode 4中迷失了方向。*它看起來完全沒有使用IB。所有的TabBarController代碼都在代碼中。Xcode 4中沒有mainwindow.xib混淆瞭如何讓我的TabBarController使用NavigationController
問:如何將NavigationBarController添加到Xcode在使用TabBarController模板時生成的默認代碼?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
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;
}
嗨,哇,兩個答案都是正確的。我現在正在使用代碼路由。 –