【发布时间】:2016-10-07 11:14:06
【问题描述】:
我正在尝试在 iOS 10 和 Swift 3 中测试 unwind segue。
我在 TableViewController 类中添加 segue 代码并连接“取消”按钮并在表视图控制器场景上退出:
@IBAction func unwindToRootViewController(segue: UIStoryboardSegue) {
print("Unwind to Root View Controller")
}
但我的简单转场不起作用。我做错了什么?
【问题讨论】:
-
如果你在
segue之前添加一个 _ 会发生什么情况:@IBAction func unwindToRootViewController(_ segue: UIStoryboardSegue)(然后你可能需要在 Interface Builder 中重新连接你的 segue) -
@pbodsk 我尝试了两个:
_segue和_ segue,但它不起作用。我的教育项目有同样的问题:github.com/IlyaGutnikov/SwiftStoryBoardsTutorial -
哦...我刚刚注意到您说您在
TableViewController中添加了segue 的代码,不应该在“外部”ViewController中吗? (看看这里:spin.atomicobject.com/2014/10/25/ios-unwind-segues) -
@pbodsk 是的,你是对的。我不得不将 segue 代码添加到我的
ViewController。谢谢! -
不客气,我会冒昧地在结果中添加答案,好吗?
标签: ios swift swift3 segue unwind-segue