【问题标题】:Programmatically Unwind Segue?以编程方式展开 Segue?
【发布时间】:2015-12-02 04:24:56
【问题描述】:

我有 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”没有任何关联”

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

我做错了什么?

【问题讨论】:

标签: ios swift segue


【解决方案1】:

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

解决方案:点击“Unwind segue to 'Exit'”,在右侧面板,'Storyboard Unwind Segue',你会看到。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-20
    • 1970-01-01
    • 2017-10-03
    • 2012-03-29
    • 1970-01-01
    相关资源
    最近更新 更多