我有一个基于窗口的应用程序。我添加了两个视图控制器和一个Tabbarcontroller
。现在我想将每个视图控制器导航到下一个视图。我试过但找不到解决方案。谁能帮帮我吗?
问问题
232 次
3 回答
2
当您在窗口上添加标签栏时,添加如下 -
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];
你会得到你想要的。:)
于 2011-03-04T05:25:35.457 回答
1
UINavigationController *urNavController = [[UINavigationController alloc] initWithRootViewController:rootController];
如果你想在窗口上显示这个
[window addSubview:urNavController.view];
于 2011-03-04T05:26:19.520 回答
1
像这样使用
secondViewController *obj=[[[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil] autorelease];
UINavigationController *navBar=[[UINavigationController alloc] initWithRootViewController:obj];
[self.navigationController pushViewController:navBar animated:YES];
[navBar release];
于 2011-03-04T05:27:14.753 回答