unwind segue vs. popViewControllerAnimated

后端 未结 1 1115
情深已故
情深已故 2021-01-24 04:25

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

相关标签:
1条回答
  • 2021-01-24 05:21

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

    0 讨论(0)
提交回复
热议问题