Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How unwindForSegue:towardsViewController: works?

In my simple app, I have created some controllers with basic segues between them:

Yellow controller -> BlueController -> GreenController -> OrangeController. Every of them has its own custom class.

From OrangeController I created unwindSegue to my YellowController. It is ok.

Within every class I put:

override func unwindForSegue(unwindSegue: UIStoryboardSegue, towardsViewController subsequentVC: UIViewController) {
    print(unwindSegue)
    print(subsequentVC)
}

But it was not called at all. Why? What demo should I prepare to test this functionality?

The same is with:

func allowedChildViewControllersForUnwindingFromSource(source: UIStoryboardUnwindSegueSource) -> [UIViewController]
func childViewControllerContainingSegueSource(source: UIStoryboardUnwindSegueSource) -> UIViewController?
like image 620
Bartłomiej Semańczyk Avatar asked Jul 19 '15 08:07

Bartłomiej Semańczyk


1 Answers

Implement the method with IBAction returnType

-(IBAction) unwindForSegue:(nonnull UIStoryboardSegue *)unwindSegue towardsViewController:(nonnull UIViewController *)subsequentVC

In Storyboard, link the control (which is responsible for the back action) to the exit action in the viewcontroller. enter image description here

enter image description here

like image 109
Saranya Sivanandham Avatar answered Sep 19 '22 03:09

Saranya Sivanandham