iphone - 从 UIViewController A 到 B 并获得反馈

标签 iphone ios objective-c

<分区>

我通过这段代码从 View Controller A 转到 B:

[self presentViewController:B animated:YES completion:^{
    }];

当 View B 被关闭时如何通知我以及此时我如何将一些参数从 B 回传给 A?

最佳答案

当需要关闭 View Controller B 时,使用以下方法:

// This code goes inside View Controller B. Here "self.presentingViewController"
// refers to View Controller A
[self.presentingViewController dismissViewControllerAnimated:YES completion:^{
    //completion code here
}];

// In your View Controller A implement dismissViewControllerAnimated:completion:
// and call super. This code goes in View Controller A
-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
    // Here you can add your custom code. 
    [super dismissViewControllerAnimated:flag completion:completion];
}

这样 View Controller A 就会知道 View Controller B 何时被关闭。

希望这对您有所帮助!

关于iphone - 从 UIViewController A 到 B 并获得反馈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18473242/

上一篇:ios - 无法访问序列化的 JSON 数据(NSJSONSerialization)

下一篇:ios - 无法使用 MPMoviePlayerController 播放视频文件

相关文章:

ios - 找出superview的类名

ios - 如何创建一个动态大小的数组

iphone - xcode 5 : What's the best way to go back and forth between top of editor and where you were before?

iphone - iOS应用保护

ios - 如何缩放和更改父 View 的原点并在 subview 中实现?

ios - 在 UIImageView 中画线

ios - 使用 uitableviewcell 内的 uiscrollview 设置页面控件

ios - 如何使用 iphone 相机渲染 GLKView Controller

javascript - 检测是否支持&lt;input type ="file"/>

ios - objective-c 中具有双 y 轴的多个条形图