导航回主 ViewController 解雇ViewControllerAnimated 困境
我有 2 个 ViewController 直接与推送序列连接。我通过调用 [self PerformSegueWithIdentifier:@"segueIdentifier" sender:sender]
从第一个视图控制器导航到第二个视图控制器。在第二个方法中,我有一个绑定到“完成”按钮的 IBAction 方法。按下该按钮基本上应该会导致显示第一个视图控制器(类似于后退按钮)。我设法做到了这一点:
NSArray *viewControllers = self.navigationController.viewControllers;
[self.navigationController popToViewController:[viewControllers
objectAtIndex:0] animated:YES];
我确实尝试通过使用来达到相同的效果:
[self dismissViewControllerAnimated:YES completion:nil];
不管我尝试了什么,尽管这没有完成工作。我试图了解我到底错过了什么,但我无法弄清楚。 missViewControllerAnimated 方法是否仅适用于 Modal segues(这是唯一想到的)。
谢谢
I have 2 ViewControllers directly connected with a push segue. I am navigating from first to second view controller by calling [self performSegueWithIdentifier:@"segueIdentifier" sender:sender]
. On the second one I have an IBAction method that is bound to a "Done" button. Pressing that button should basically cause the first view controller to be displayed (sort of a back button). I managed to do that with:
NSArray *viewControllers = self.navigationController.viewControllers;
[self.navigationController popToViewController:[viewControllers
objectAtIndex:0] animated:YES];
I did try to achieve the same effect by using:
[self dismissViewControllerAnimated:YES completion:nil];
No matter what I tried though this didn't do the job. I am trying to understand what exactly am I missing but I can't figure it out. Does dismissViewControllerAnimated method work only with Modal segues ( this is the only thing that came to mind ).
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,
就是当 UIViewController 以模态方式显示时。
应该做你正在寻求的事情。
所以基本上,在你的第二个 VC 中:
如果你阅读 UIViewController 和 UINavigationController 参考资料,你会省去很多麻烦。两次;)
Yes,
is when a UIViewController is displayed modally.
should do what you are seeking.
So basically, in your second VC:
You will save you a lot of trouble if you read the UIViewController and UINavigationController references. Twice ;)