为什么故事板退出按钮中缺少IBAction方法?

时间:2016-11-01 18:00:33

标签: ios swift xcode

我正在尝试执行展开segue。我在一个全新的项目中测试了我的逻辑,并且能够验证模式。但是在我的实际工作项目中,相同的模式不起作用。

我正试图从SettingsControllerEditorViewController放松。但是,我@IBAction内的EditorViewController未显示在SettingsController的退出情节提示按钮中。

EditorViewController.swift

class EditorViewController: UIViewController {
    // Snippet
    @IBAction func unwindToEditor(segue: UIStoryboardSegue) {
        // Some logic
    }
}

将segue从一个控制器拖放到另一个控制器

Creating a Push Segue between controllers

尝试将EditorViewController#unwindToEditor与SettingsController关联

As you can see the unwindToEditor method is missing

unwindToEditor方法不可用。

我尝试但没有帮助的事情:

  • 重新启动Xcode
  • 从视图控制器中删除自定义类并再次添加
  • 删除Xcode的派生数据
  • 创建自定义Obj-C头文件
  • 在我的展开操作中使用了多个方法签名

注意:

我发现这个可用的IBActions列表在"呈现Segues"在'退出'控制器的按钮仅从我的一个控制器中拉出。也许在多个控制器中填充此列表存在问题?

发现

的工作

似乎即使我的方法在列表中缺失,如果我选择其中一种方法并且在unwind segue的属性检查器中手动更改方法调用,它将调用相应的(这是失踪)方法。

1 个答案:

答案 0 :(得分:0)

您不需要展开segue方法。

只需这样做:

  1. EditorViewController添加此代码:

    @IBAction func unwindToEditorViewController(segue: UIStoryboardSegue) {}
    
  2. SettingsController控件上
  3. 从您的按钮拖动到SettingsController的退出图标,然后从列表中选择unwindoToEditorViewController

    enter image description here

  4. 瞧!