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

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

问题描述

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

I have 2 view controllers presented modally.

A presents B which presents C.

当我关闭CI时也想关闭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天全站免登陆