如何使用UINavigationController从一个视图中推送多个视图 [英] How do I push many Views from one View using UINavigationController

查看:81
本文介绍了如何使用UINavigationController从一个视图中推送多个视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 UINavigationController 编写了许多转换应用程序。

I code many transition App using UINavigationController.

这是我的转换图片

This is my transition image


  1. Main - >Second - >Third - >Fourth

  2. Second - >A - >B

  3. Second - >C

  4. Third - >D

  1. "Main"-->"Second"-->"Third"-->"Fourth"
  2. "Second"-->"A"-->"B"
  3. "Second"-->"C"
  4. "Third"-->"D"


  • Main是RootViewController。

  • 在No2和No3, if([booisEqual:foo]){transitA} else if(boo......){transitC}

  • "Main" is RootViewController.
  • At No2 and No3, if (["boo" isEqual:"foo"]){transit "A"} else if ("boo"...){transit "C"}.

我可以将Main改为Forth ,No.1过渡。

喜欢这个

I could make "Main" to "Forth", No.1 transition.
like this

ThirdViewController *thirdView = [[ThirdViewController alloc] init];
[self.navigationController pushViewController:thirdView animated:YES];

但我无法将秒变为A和B。

我想把UIRootViewController设置为Second。

但是Second需要转换A和C。

But I can't make "Second" to "A"and "B".
I thought to set UIRootViewController to "Second".
But "Second" needs to transit "A" and "C".

atSecond就像这样......

at "Second" like this...

SecondViewController.m

AViewController *aView = [[AViewController alloc] init];
[self.navigationController pushViewController:aView animated:YES];

我如何编码?

谢谢您!对不起英语不好。

请帮帮我!

Thank you! And sorry in poor English.
Please help me!

推荐答案

NSInteger index = 0;
for (UIViewController *view in self.navigationController.viewControllers) {
    if([view.nibName isEqualToString:@"RootViewController"])//put any `XIB name` where u want to navigate 
        break;
    index = index + 1;
}
[[self navigationController] popToViewController:[[self.navigationController viewControllers] objectAtIndex:index] animated:YES];    

这篇关于如何使用UINavigationController从一个视图中推送多个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆