关闭模态视图 [英] Dismiss Modal View

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

问题描述

如果我没记错的话,必须将模态视图从父视图中移除,而不是从模态视图本身中移除.

If I'm not mistaken, modal views have to be dismissed from the parent view, not from the modal view itself.

在我当前的项目中,我有两个模式视图.在第一个中,我将数据传递到父视图.当数据传递到父视图时,将执行关闭操作.

In my current project I have two modal views. In the first one, I pass data to the parent view. When the data is passed to the parent view, the dismiss is executed.

现在,我有另一个模式视图,该视图不会将数据传递给父视图,因此除了做一个自已的dismissModalView之外,我不知道该如何关闭

Now, I have another modal view that doesn't pass data to the parent view, so I don't know how to dismiss other than doing one self dismissModalView

除此之外,关于此主题的良好实践还有其他建议吗?

Other than that, any other suggestion for a good practise on this topic?

提前谢谢!

更新:

从我得到的答案中,我发现自己并没有很清楚(顺便说一句,顺便说一句).

From the answers I´m getting, I see I haven´t make myself very clear (not unusual, BTW).

我知道如何自我解散modalViewController.那没问题. 我还知道当传递一些数据时,如何使用protocol-delegate方法从父视图中关闭modalViewController.

I know how to self dismiss a modalViewController. That´s no problem. I also know how to use the protocol-delegate method to dismiss the modalViewController from the parent view when some data is passed.

我的问题是:当没有数据传递时,如何从父视图中关闭modalViewController.

My question is: how to dismiss the modalViewController from the parent view when no data is passed.

再次感谢!

推荐答案

您可以从modalView中调用:

You can call from the modalView :

[self dismissModalViewControllerAnimated:YES];

但是...如果您希望有一个恒定的编码模式,无论模态视图是否返回"某种东西,我建议您从父级关闭视图(调用的视图,关闭的视图).但是你可以两者都做.

But... If you want to have a constant coding pattern, whatever the modal view "returns" something or not, I suggest you to dismiss you views from the parent (the one that calls, the one that dismiss). But you can do both.

这能回答您的问题吗?

这篇关于关闭模态视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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