我使用UINavigationController
编码了许多过渡应用。
这是我的过渡形象
“第三” - > “中d”
if (["boo" isEqual:"foo"]){transit "A"} else if ("boo"...){transit "C"}
。我可以将“主要”变为“第四”,第一过渡 像这样的
ThirdViewController *thirdView = [[ThirdViewController alloc] init];
[self.navigationController pushViewController:thirdView animated:YES];
但是我不能把“第二”变成“A”和“B”
我想将UIRootViewController设置为“Second”
但“第二”需要通过“A”和“C”。
SecondViewController.m
AViewController *aView = [[AViewController alloc] init];
[self.navigationController pushViewController:aView animated:YES];
我该如何编码?
谢谢!抱歉英语不好 请帮帮我!
答案 0 :(得分:2)
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];
答案 1 :(得分:0)
尝试使用此代码推送到控制器
DrawImgViewcontroller *ObjImageViewController = [[DrawImgViewcontroller alloc] initWithNibName:@"DrawImgViewcontroller" bundle:nil];
[self.navigationController pushViewController:ObjImageViewController animated:YES];
[ObjImageViewController release];
并使用下面的代码返回
[self.navigationController popViewControllerAnimated:YES];
并将其用于您喜欢的任何控制器
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:NO];//Instead of one you can use the currect index you need