在关闭控制器时将值传递给父控制器 [英] Pass value to parent controller when dismiss the controller
本文介绍了在关闭控制器时将值传递给父控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将数据发送到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的控制器名称:动画:完成
方法。
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屋!
查看全文