我有两个视图控制器以模块方式呈现.

A presents B which presents C.

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

C:

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

现在我只剩下B了.我怎样才能把B从C中剔除呢?

推荐答案

try 使用B中的下一个代码(就像你已经做的那样,在go 掉C之后):

[self.parentViewController dismissModalViewControllerAnimated:YES];

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

更新:

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

Objective-c相关问答推荐

如果DISPATCH_SOURCE_SET_EVENT_HANDLER中的SELF需要为弱

如何使用 iOS 7 SpriteKit 粒子向非游戏的 iOS 应用程序添加粒子效果?

如何以编程方式获取iphone的IP地址

UIButton 标题更改为默认值

如何追踪 SIGABRT 的原因

如何向 UILabel 添加滚动功能

iOS 编译错误:CDVCommandDelegateImpl没有可见的@interface 声明 Select 器执行:

如何将 UInt32 设置为最大值

带有 AVPlayer 的多个视频

如何获得本地化的 Cancel、Done 等?

在 NSNumbers 的 NSArray 中查找最小值和最大值

我可以设置 `UILabel` 的 `attributedText` 属性吗

如何编写 OS X Finder 插件

如何用 Java 开发 iPhone 应用程序?

Select 时 UITableViewCell 复选标记更改

添加/删除带有动画的 UITableViewCell?

何时在 iPhone 上使用 UIView 与 UIViewController?

-[MyClassName copyWithZone:] 无法识别的 Select 器发送到实例

移除所有 CALayer 的子层

在 iOS 6.0 的 Xcode 4.5 中我没有要求的日志(log)消息