2016-11-01 63 views
0

我正試圖執行一個unwind segue。我已經在一個全新的項目中測試了我的邏輯,並且能夠驗證模式。但是在我的實際工作項目中,相同的模式不起作用。爲什麼故事板退出按鈕中缺少IBAction方法?

我試圖從我的SettingsController放鬆到我的EditorViewController。但裏面的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頭文件
  • 在我的展開動作上使用多個方法簽名

注意:

我發現在控制器的「退出」按鈕下的「呈現分段」中的可用IBA列表僅從我的一個控制器拉出。在多個控制器中填充此列表可能存在問題?

發現變通

看來,即使我的方法是從列表中缺少的,如果我去選擇的方法之一是確實存在並手動更改方法開卷SEGUE的屬性檢查器中調用它會調用適當的(缺少的)方法。

+0

你正在使用哪個版本的swift? –

+0

Swift 3和Xcode 8.1 – pyRabbit

+0

swift 3強調命名參數要麼給一個或忽略爲'@IBAction func unwindToEditor'(_ segue:UIStoryboardSegue)' –

回答

0

你不需要一個unwind segue方法。

只要做到這一點:

  1. EditorViewController添加以下代碼:從您的按鈕

    @IBAction func unwindToEditorViewController(segue: UIStoryboardSegue) {} 
    
  2. SettingsController調速拖動到SettingsController退出圖標,然後從列表中選擇unwindoToEditorViewController

    enter image description here

瞧!

+0

這就是問題,在步驟2中unwindToEditorViewController丟失 – pyRabbit

+0

如果您有任何錯字像我在#1上輸入的代碼?你把代碼放在你想要返回的控制器上,對吧? – SpaceDog

+0

當你在這裏,嘗試[我的其他解決方案](http://stackoverflow.com/a/38659848/316469)。 – SpaceDog