我有UINavigationController
。我加载了presentmodalviewcontroller
。我在presentmodalviewcontroller
上推出了2个以上的视图控制器。如果我需要移动到我的第一个视图控制器,应该做什么?
编辑:我还在我的堆栈顶部的UIView
上加载了一些UIViewController
。我已经成功删除了它。
我试过了
[self.navigationController popToRootViewControllerAnimated:YES];
[self.navigationController dismissModalViewControllerAnimated:YES];
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES];
但仍无效
这就是我添加每个视图控制器的方式
第一个视图控制器
FirstViewController *firstViewController =
[[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];
UINavigationController *navcontrol =[[UINavigationController alloc]initWithRootViewController:firstViewController];
[self presentModalViewController:navcontrol animated:YES];
[navcontrol release];
第二个视图控制器
SecondViewController *secondViewController = [[SecondViewController alloc]init] ;
[self.navigationController pushViewController: secondViewController animated:YES];
[secondViewController release];
第三个视图控制器
ThirdViewController *thirdViewController = [[ThirdViewController alloc] init];
[self.navigationController pushViewController: thirdViewController animated:YES];
[thirdViewController release];
答案 0 :(得分:0)
确定。我懂了。
myAppDelegate *appDelegate = (myAppDelegate*)[UIApplication sharedApplication].delegate;
[appDelegate.navigationController dismissModalViewControllerAnimated:YES];