当存在多个ViewControllers / segues时,DismissViewControlers [英] DismissViewControlers when Multiple ViewControllers/segues are present

查看:81
本文介绍了当存在多个ViewControllers / segues时,DismissViewControlers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个ViewController的以下场景
VC2中有一个按钮。

I have the following scenario with three ViewController's There is a button in VC2.

用户已登录案例:
点击VC2中的此按钮将转到VC3,即我有从VC2到VC3的推送

User Already Logged-in Case : Clicking on this button in VC2 will take you to VC3 , i.e I have a push-segue from VC2 to VC3

用户尚未登录案例:
点击按钮,将转到LoginVC(模式segue),成功登录后,用户将转到VC3 ((模态segue)然后用户可以点击返回按钮返回VC2。
即,VC2将呈现LoginVC,LoginVC将呈现VC3。

User Not Already Logged-in Case: Clicking on the button , will take you to LoginVC(modal segue) ,On successfull-login ,User will go to VC3((modal segue) and then the user can go back to VC2 on clicking back button. i.e, VC2 will present LoginVC , LoginVC will present VC3.

Question-1
我如何以这种方式解雇VC。根据我解雇VC的知识,父委托方法负责解雇孩子VC。但是我有一个Vc链成功登录后,我们从loginVC转到VC3。当从VC3回到VC2时,谁应该解雇VC3?

Question-1 : How do I go about dismissing VC's in this manner. Per my knowledge of dismissing VC's , parent delegate method is responsible for dismissing child VC. However I have a chain of Vc's forming a loop. On Successful login, we go from loginVC to VC3. When going back to VC2 from VC3, who should dismiss VC3?

Question-2
VC2 - VC3是推送segue。 LogicVC到VC3是模态segue。这是正确的吗?

Question-2: VC2 - VC3 is a push segue. LogicVC to VC3 is a modal segue. Is this correct ?

推荐答案

我建议你重新考虑一下你的流程。为什么 LoginVC 模态 segue中显示 VC3 并不合理。相反,如果需要登录,您应该从 VC2 LoginVC 模型 segue,如果登录成功,请关闭此 LoginVC ,您可以通过<$ c $在 LoginVC 中解除c> [self dismissViewControllerAnimated:YES completion:nil]; 并在导航中显示 VC3 segue方式。

I suggest you to rethink your flow a little bit. Doesn't really make sense why your LoginVC presents VC3 in modal segue. Rather you should have a model segue from VC2 to LoginVC in case login is required, and if the login is success, dismiss this LoginVC, which you can dismiss in the LoginVC itself by [self dismissViewControllerAnimated:YES completion:nil]; and present the VC3 in a navigation segue manner.

负责解雇孩子VC的父母并非总是如此。孩子VC可以解雇自己。如果您仍想以自己的方式实现,那么您的 VC3 应首先解雇自己,然后,取决于您是否要显示 LoginVC 或不是,你可以在完成块中解除 LoginVC

It is not always the parent who is responsible for dismissing the child VC. The child VC's can dismiss themselves. If you still want to achieve in your manner, then your VC3 should first dismiss itself, and then, depending upon whether you want to show your LoginVC or not, you can dismiss the LoginVC in the completion block.

关于你的问题2,真的没有意义。你问我们你的系统流程应该如何?你可以有任何符合你要求的segue。

About your question 2, really makes no sense. Are you asking us how your system flow should look like? You can have any kind of segue which matches your requirements.

如果这有帮助,请告诉我。

Let me know if this helps.

这篇关于当存在多个ViewControllers / segues时,DismissViewControlers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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