如何连续关闭 2 个模态视图控制器? [英] How to Dismiss 2 Modal View Controllers in Succession?

查看:18
本文介绍了如何连续关闭 2 个模态视图控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 2 个以模态方式呈现的视图控制器.

I have 2 view controllers presented modally.

A presents B which presents C.

当我解雇 C 时,我也想解雇 B.但我不知道该怎么做:

When I dismiss C I would like to dismiss B as well. But I am not sure how to do this:

关闭 C:

[self dismissModalViewControllerAnimated:YES]
//[delegate dismissB] //this doesn't work either when i create a delegate pattern

现在我只剩下 B.我怎样才能从 C 中解雇 B?

Now I am left with B. How can I dismiss B from C?

推荐答案

尝试使用 B 中的下一个代码(在关闭 C 之后,就像你已经做的那样):

Try using the next code in B (right after dismissing C, as you already do):

[self.parentViewController dismissModalViewControllerAnimated:YES];

重要事项:
在此行之后的方法中不要做任何事情.
这个视图控制器 (B) 可能会被释放和释放...

IMPORTANT:
Don't do anything in the method after this line.
This view controller (B) probably will be released and deallocated...

更新:
从 iOS7 开始,不推荐使用上述方法.
改用下一个方法:

UPDATE:
Starting from iOS7 the method above is deprecated.
Use the next method instead:

[self.parentViewController dismissViewControllerAnimated:YES completion:^{ /* do something when the animation is completed */ }];

这篇关于如何连续关闭 2 个模态视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆