Iphone 如何将导航控制器添加到基于窗口的应用程序
我有一个基于窗口的应用程序。我添加了两个ViewController和一个Iphone 如何将导航控制器添加到基于窗口的应用程序,iphone,objective-c,xcode,viewcontroller,Iphone,Objective C,Xcode,Viewcontroller,我有一个基于窗口的应用程序。我添加了两个ViewController和一个Tabbarcontroller。现在,我想将每个viewcontroller导航到下一个视图。我试过了,但找不到解决办法。有人能帮我吗?当您在窗口上添加选项卡栏时,按如下方式添加- NSMutableArray * viewControllers = [[NSMutableArray alloc]init]; FirstViewController * firstViewController = [[FirstVie
Tabbarcontroller
。现在,我想将每个viewcontroller导航到下一个视图。我试过了,但找不到解决办法。有人能帮我吗?当您在窗口上添加选项卡栏时,按如下方式添加-
NSMutableArray * viewControllers = [[NSMutableArray alloc]init];
FirstViewController * firstViewController = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil];
UINavigationController * nvc = [[UINavigationController alloc] initWithRootViewController:firstViewController];
[firstViewController release];
[viewControllers addObject:nvc];
[nvc release];
SecondViewController * secondViewController = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
nvc = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[secondViewController release];
[viewControllers addObject:nvc];
[nvc release];
UITabBarController * tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = viewControllers;
[window addSubview:tabBarController.view];
编辑-
当您想要在任何一个控制器中导航时。你只需要打个电话
[self.navigationController pushViewController:anotherViewController animated:YES];
你会得到你想要的东西。:) 在窗口上添加选项卡栏时,按如下方式添加-
NSMutableArray * viewControllers = [[NSMutableArray alloc]init];
FirstViewController * firstViewController = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil];
UINavigationController * nvc = [[UINavigationController alloc] initWithRootViewController:firstViewController];
[firstViewController release];
[viewControllers addObject:nvc];
[nvc release];
SecondViewController * secondViewController = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
nvc = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[secondViewController release];
[viewControllers addObject:nvc];
[nvc release];
UITabBarController * tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = viewControllers;
[window addSubview:tabBarController.view];
编辑-
当您想要在任何一个控制器中导航时。你只需要打个电话
[self.navigationController pushViewController:anotherViewController animated:YES];
你会得到你想要的东西。:)
如果你想在窗口上显示这个
[window addSubview:urNavController.view];
如果你想在窗口上显示这个
[window addSubview:urNavController.view];
像这样使用
secondViewController *obj=[[[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil] autorelease];
UINavigationController *navBar=[[UINavigationController alloc] initWithRootViewController:obj];
[self.navigationController pushViewController:navBar animated:YES];
[navBar release];
像这样使用
secondViewController *obj=[[[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil] autorelease];
UINavigationController *navBar=[[UINavigationController alloc] initWithRootViewController:obj];
[self.navigationController pushViewController:navBar animated:YES];
[navBar release];
发布你的代码,可能更容易看出为什么事情不适合你。发布你的代码,可能更容易看出为什么事情不适合你。