I code many transition App using UINavigationController
.
This is my transition image
- "Main"-->"Second"-->"Third"-->"Fourth"
- "Second"-->"A"-->"B"
- "Second"-->"C"
"Third"-->"D"
- "Main" is RootViewController.
- At No2 and No3,
if (["boo" isEqual:"foo"]){transit "A"} else if ("boo"...){transit "C"}
.
I could make "Main" to "Forth", No.1 transition.
like this
ThirdViewController *thirdView = [[ThirdViewController alloc] init];
[self.navigationController pushViewController:thirdView animated:YES];
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".
at "Second" like this...
SecondViewController.m
AViewController *aView = [[AViewController alloc] init];
[self.navigationController pushViewController:aView animated:YES];
How can I code?
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];
Try this code to push to a controller
DrawImgViewcontroller *ObjImageViewController = [[DrawImgViewcontroller alloc] initWithNibName:@"DrawImgViewcontroller" bundle:nil];
[self.navigationController pushViewController:ObjImageViewController animated:YES];
[ObjImageViewController release];
and use below code to go back
[self.navigationController popViewControllerAnimated:YES];
and use this to any controller you like
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:NO];//Instead of one you can use the currect index you need