ios - Swift:在展开期间 performSegueWithIdentifier 不起作用

标签 ios swift unwind-segue

我创建了一个典型的展开流程,从我的 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/

相关文章:

ios - 我无法正确收集响应。当我设置断点时它工作正常但没有断点它没有给出正确的结果

ios - 如何从数组显示 fs 日历中的事件点

swift - IOS 8 AVAudioRecorder 更改示例格式

swift - Vapor 3 Swift 4 如何制作计时器

swift - 如何使用表单数据或任何其他方法快速上传 PDF 文件

ios - UITableViewController 作为数据输入屏幕(iOS、Swift)和日历应用程序 "New Event"屏幕

ios - 放松不起作用

ios - 如何检查我的高通云台信标是否正常工作?

iphone - iOS:无法识别 subview 上的手势

xcode - 在不同的导航堆栈中展开到 viewController 不起作用