关闭控制器时将值传递给父控制器 [英] Pass value to parent controller when dismiss the controller

查看:30
本文介绍了关闭控制器时将值传递给父控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将数据发送到 parentviewcontroller 但以下代码崩溃.给我解决方案

I want to send data to parentviewcontroller but the following code crashes. Give me the solution

Post *vc;
vc.abc =@"Comment Conttroller";
[self.parentViewController dismissModalViewControllerAnimated:YES];

这里,Post 是我调用 presentViewController:animated:completion 方法的控制器名称.

Here, Post is the controller name from where I am calling the presentViewController:animated:completion method.

推荐答案

vc 似乎没有被初始化.

你可能会这样做,

vc = (Post *)self.parentViewController;
vc.abc = @"Comment Conttroller";
[vc dismissModalViewControllerAnimated:YES];

由于您想要影响的视图控制器是 parentViewController,您应该能够转换和设置 abc 属性.

Since the view controller you want to affect is the parentViewController, you should be able to cast and set the abc property.

这篇关于关闭控制器时将值传递给父控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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