我创建了一个典型的展开流程,从我的 View Controller #2 返回到 View Controller #1,使用以编程方式创建的按钮,使用 segue to Exit 技术。
我有跟踪语句确认按钮代码正在完美执行,并且正在使用正确的 segue ID 调用 #2 performSegueWithIdentifier 函数,但没有任何反应。
澄清:
我已将 View Controller #2 连接到 Exit 并确认 segue ID 在所有地方都是准确的。我在 #2 performSegueWithIdentifier 函数中追踪了 #2 标识符,它完全匹配。
据我所知,我不再需要对当前版本的 2016 XCode 使用 dispatch 修复。无论如何我都试过了,但没有任何效果。没有崩溃,只是没有放松。
不知何故,放松技术并没有使用这种退出技术来逆转。有什么想法吗?
我一直在关注这里的教程:https://spin.atomicobject.com/2014/12/01/program-ios-unwind-segue/
代码 VC#2:
// action func wired to button, fires perfectly
func unwind(seg:UIStoryboardSegue!) {
self.performSegueWithIdentifier("unwind", sender: self)
}
最佳答案
在 VC1 中你需要一个函数:
@IBAction func unwindToVC1(segue:UIStoryboardSegue) {
}
然后在你的 Storyboard中按住 ctrl 从黄色 View Controller 图标拖动到退出图标并从弹出窗口中选择 unwindToVC1:
给 unwind segue 一个标识符,比如 unwindToVC1
现在,在 VC2 中,创建您的按钮 touchUpInside
处理程序:
func buttonTapped(sender:UIButton) {
self.performSegueWithIdentifier("unwindToVC1")
}
当您以编程方式设置按钮时,将此方法添加为操作处理程序:
button.addTarget(self, action: "buttonTapped:", forControlEvents: .TouchUpInside)
关于ios - Swift:在展开期间 performSegueWithIdentifier 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36081080/