我正在使用 Xcode 4.4.1。我创建了一个简单的基于选项卡的应用程序。然后我想将导航控制器添加到应用程序中。谁能告诉我如何在 Xcode 4.4.1 中做到这一点。我当前的代码是这样的,但它不起作用。
`
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[Addbills alloc]initWithNibName:@"Addbills" bundle:nil];
UIViewController *viewController3 = [[CalenderView alloc]initWithNibName:@"CalenderView" bundle:nil];
UIViewController *viewController4 = [[Web alloc]initWithNibName:@"Web" bundle:nil];
UIViewController *viewController5 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:viewController1];
[self.navigationController setNavigationBarHidden:TRUE];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[viewController1,viewController2,viewController3,viewController4,viewController5];
self.window.rootViewController = self.tabBarController;
// self.window.rootViewController =self.navigationController;
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
return YES;
}
`
这是我在 viewController5 中的按钮单击事件
`
- (IBAction)backToPrevious:(id)sender {
[self.navigationController popToRootViewControllerAnimated:TRUE];
}`
谢谢,