如何unwindForSegue:towardsViewController:有效吗?

时间:2015-07-19 08:40:53

标签: ios swift ios9 uistoryboard uistoryboardsegue

在我的简单应用程序中,我创建了一些控制器,它们之间有基本的段落:

黄色控制器 - > BlueController - > GreenController - > OrangeController 即可。他们每个人都有自己的自定义类。

OrangeController 我创建了unwindSegue到我的 YellowController 。没关系。

在我提出的每个课程中:

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

但它根本没有被召唤。为什么?我应该准备什么样的演示来测试这个功能?

同样如下:

func allowedChildViewControllersForUnwindingFromSource(source: UIStoryboardUnwindSegueSource) -> [UIViewController]
func childViewControllerContainingSegueSource(source: UIStoryboardUnwindSegueSource) -> UIViewController?

1 个答案:

答案 0 :(得分:7)

使用IBAction returnType

实施该方法
-(IBAction) unwindForSegue:(nonnull UIStoryboardSegue *)unwindSegue towardsViewController:(nonnull UIViewController *)subsequentVC

Storyboard中,将控件(负责后退操作)链接到viewcontroller中的退出操作。 enter image description here

enter image description here