Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何将导航控制器添加到基于窗口的应用程序_Iphone_Objective C_Xcode_Viewcontroller - Fatal编程技术网

Iphone 如何将导航控制器添加到基于窗口的应用程序

Iphone 如何将导航控制器添加到基于窗口的应用程序,iphone,objective-c,xcode,viewcontroller,Iphone,Objective C,Xcode,Viewcontroller,我有一个基于窗口的应用程序。我添加了两个ViewController和一个Tabbarcontroller。现在,我想将每个viewcontroller导航到下一个视图。我试过了,但找不到解决办法。有人能帮我吗?当您在窗口上添加选项卡栏时,按如下方式添加- NSMutableArray * viewControllers = [[NSMutableArray alloc]init]; FirstViewController * firstViewController = [[FirstVie

我有一个基于窗口的应用程序。我添加了两个ViewController和一个
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];

发布你的代码,可能更容易看出为什么事情不适合你。发布你的代码,可能更容易看出为什么事情不适合你。