揭开序幕vs.popViewControllerAnimated [英] unwind segue vs. popViewControllerAnimated

查看:121
本文介绍了揭开序幕vs.popViewControllerAnimated的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个连接到多个viewController的mapview.

I have a mapview that is connected to several viewControllers.

我需要从另一个按钮(而不是仅是后退按钮)实现展开",所以我使用了:

I needed to implement an 'unwind' from another button (as opposed to just the back button), so I used:

self.navigationController?.popViewControllerAnimated(true)

我的问题是:随着上述工作的进行,我是否应该还要尝试在父视图控制器中使用prepareForUnwindcanPerformUnwindSegueAction在代码中展开展开,并从viewController中按住ctrl拖动以在Storyboard中退出?如果是这样,为什么?

My question is: as the above works, should I even bother trying to implement unwind in code using prepareForUnwind and canPerformUnwindSegueAction in the parent view controller + ctrl-drag from the viewController to exit in Storyboard? If so, why?

推荐答案

基本上,如果您只是dimissing演示的UIViewController或从导航堆栈中弹出UIViewController,则无需使用展开键尽管对您来说也一样.

Basically if you are just dimissing a presented UIViewController or popping a UIViewController from the navigation stack,you don't need to use unwind segues although it does the same for you.

但请考虑以下情况:先出现UINavigationControllers A,B,C ,然后出现RootViewController R

But think of a case where there are UINavigationControllers A,B,C and then a RootViewController R

然后考虑条件

 (Present) R -> A
 (Push) AR -> XVController
 (Push)XVController -> B
 (Present)BR-> YVContoller
...and so on..

现在如果要返回到YVController到刚启动的项目RootViewController,则无法将popToRootViewController弹出到B UINavigationController的导航堆栈中.委托或更改RootViewController窗口这不是一个好主意.

Now if you want to go back to YVController to your project RootViewController where you just started up.There is no way as popToRootViewController pops to the navigation stack of the B UINavigationController.Now what you do..Either use delegate or change window RootViewController which is not a good idea.

因此,您需要使用放松搜索来解决此问题.项目以演示其使用的强大功能.

So you need to use unwind segue to overcome this.. A sample project to demonstrate the power of using it..

这篇关于揭开序幕vs.popViewControllerAnimated的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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