unwind segue vs. popViewControllerAnimated

微笑、不失礼 提交于 2019-12-02 04:55:31

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.

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

Then think of a condition

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

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..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!