How unwindForSegue:towardsViewController: works?

余生颓废 提交于 2019-12-03 09:58:57

问题


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?

回答1:


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.



来源:https://stackoverflow.com/questions/31499406/how-unwindforseguetowardsviewcontroller-works

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