简体   繁体   English

弹出项目的第一个视图控制器

[英]Popping to first view controller of the project

I have a UINavigationController . 我有一个UINavigationController I load a presentmodalviewcontroller over it. 我加载了一个presentmodalviewcontroller And I push 2 more view controllers over the presentmodalviewcontroller . 我推2个视图控制器在presentmodalviewcontroller If I need to move to my first view controller, what should be done? 如果我需要移至第一个视图控制器,应该怎么做?

Edit: I am also loading some UIView over the UIViewController on top of my stack. 编辑:我也正在堆栈顶部的UIViewController上加载一些UIView I have successfully removed that. 我已经成功删除了。

I have tried 我努力了

 [self.navigationController popToRootViewControllerAnimated:YES];
 [self.navigationController dismissModalViewControllerAnimated:YES];  
 [self.navigationController popToViewController:[self.navigationController.viewControllers   objectAtIndex:0] animated:YES]; 

but still its not working 但仍然无法正常工作

This is how I am adding each view controller 这就是我添加每个视图控制器的方式

First viewcontroller 第一个视图控制器

 FirstViewController *firstViewController = 
 [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];

 UINavigationController *navcontrol =[[UINavigationController alloc]initWithRootViewController:firstViewController];
 [self presentModalViewController:navcontrol animated:YES];
 [navcontrol release];

Second viewcontroller 第二个视图控制器

SecondViewController *secondViewController = [[SecondViewController alloc]init] ;
[self.navigationController pushViewController: secondViewController animated:YES];
        [secondViewController release];

Third viewcontroller 第三视图控制器

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

Ok. 好。 I got it. 我知道了。

    myAppDelegate *appDelegate = (myAppDelegate*)[UIApplication sharedApplication].delegate;

    [appDelegate.navigationController dismissModalViewControllerAnimated:YES];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM