以编程方式展开Segue?

时间:2015-12-02 04:24:56

标签: ios swift segue

我有2个ViewController,比方说Feed和Login。初始页面是Feed,如果未经过身份验证,则用户将被定向到“登录”页面。填写表单后,成功登录后,我正试图放松回Feed页面。

在FeedVC中,我补充道:

@IBAction func unwindToFeed(segue: UIStoryboardSegue){

}

在LoginVC中,按登录按钮

@IBAction func loginButton(sender: AnyObject) {
  func authenticatedUser (...) {

    if error != nil {
          // error handling
    } else {
         // success

        NSOperationQueue.mainQueue().addOperationWithBlock({
           self.performSegueWithIdentifier("unwindToFeed", sender: self)
        })
    }
  } 
}

但是,成功之后,它不会被解开,我收到错误

  

因未捕获的异常'NSInvalidArgumentException'而终止应用,>原因:'接收者(0x7fd789a2cab0>)没有标识符'unwindToFeed'的segue''

在Storyboard中,在LoginVC中,我还试图从黄色(ViewController)中按住Ctrl键拖动到顶部的Exit。但是,一旦我这样做,我就会收到"Segues initiated directly from view controllers must have an identifier",并在登录视图控制器场景中显示Unwind segue to 'Exit'

我做错了什么?

1 个答案:

答案 0 :(得分:0)

找到我的答案。我没有像它所说的那样命名segue。

解决方案:点击"在右侧面板上退出,然后退出'退出'"' Storyboard Unwind Segue',您将看到。