一次关闭多个模态视图控制器? [英] Dismissing multiple modal view controllers at once?
问题描述
所以有一个包含三个视图控制器的堆栈,其中 A 是根,B 是第一个模态视图控制器,C 是第三个模态 vc.我想立即从 C 转到 A.我已经尝试过 这个解决方案解雇.它确实工作,但不是以正确的方式.也就是说,当最后一个视图控制器被关闭时,它会在第一个视图控制器显示之前简单地显示第二个视图控制器.我正在寻找的是一种在一个漂亮的动画中从第三个 vc 到第一个而不注意第二个视图的方法.对此的任何帮助都非常感谢.
So have a stack with three view controllers where A is root, B is first modal view controller and C is third modal vc. I would like to go from C to A at once. I have tried this solution to dismiss.It does work but not in a correct way. That is when the last view controller is dismissed it will breifly show the second view controller before the first is shown. What I'm looking for is a way to get from the third vc to the first in one nice animation without noticing the second view. Any help on this is greatly appriciated.
推荐答案
请确保您只调用 dismissModalViewControllerAnimated:
一次.
Be sure that you're only calling dismissModalViewControllerAnimated:
once.
我发现要求关闭每个堆叠的模态视图控制器会导致它们都设置动画.
I have found that asking to dismiss each stacked modal view controller will cause both of them to animate.
你有:A =modal>B=模态>C
你应该只调用 [myViewControllerAdismissModalViewControllerAnimated:YES]
如果你使用[myViewControllerBdismissModalViewControllerAnimated:YES]
,它将关闭C,而不是B.在正常(未堆叠)使用中,它会关闭B(由于响应者链向上冒泡消息)到 A).在您描述的堆叠场景中,B 是父视图控制器,这优先于模态视图控制器.
If you use [myViewControllerB dismissModalViewControllerAnimated:YES]
, it will dismiss C, and not B. In normal (unstacked) use, it would dismiss B (due to the responder chain bubbling the message up to A). In the stacked scenario that you describe B is a parent view controller and this takes precedence over being a modal view controller.
这篇关于一次关闭多个模态视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!