【问题标题】:Receiver has no segue with identifier, though the segue is actually declared接收者没有带标识符的转场,尽管转场实际上是声明的
【发布时间】:2018-06-29 12:27:36
【问题描述】:

我正在一个新的 Swift 项目中工作,我正在尝试在按下按钮时执行segue 的简单任务。但是,每当我尝试触发 segue 时,都会弹出以下错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<Ma2Mi.LandingViewController: 0x7f99c65122b0>) has no segue with identifier 'showLogin''

比较简单,除了实际上有一个名为showLogin的segue:

(顶视图控制器的类型为LandingViewController。)

这是调用 segue 的方式:

loginButton.addAction {
    self.performSegue(withIdentifier: "showLogin", sender: nil)
}

这么简单的任务怎么会失败?也许是一个错误,或者我忽略了什么?

谢谢。

【问题讨论】:

  • LandingViewController 的实例是如何创建的?
  • @Paulw11 这都是故事板。 LandingViewController 是这个故事板的根 viewController UINavigationController
  • 也许你 ctrl 从 UI 元素而不是故事板中的视图控制器实例拖动?
  • @AndréSlotta 我已经尝试重新建立连接\
  • 可能是segue名称中的空格?如果不是,这没有任何意义。 :)

标签: ios swift xcode uistoryboardsegue


【解决方案1】:

您是否在触发 segue 的 ViewController 上使用了所需的 init() 函数?在我删除它之前,我遇到了同样的问题。

【讨论】:

    猜你喜欢
    • 2017-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-30
    • 2019-11-20
    • 1970-01-01
    • 2012-08-06
    • 1970-01-01
    相关资源
    最近更新 更多