简体   繁体   English

self.performSegue 找不到storyboard-segue-ID,即使它已被命名

[英]self.performSegue cannot find storyboard-segue-ID even though it has been named

I am trying to programmatically segue in LiveController.swift .我正在尝试以编程方式在LiveController.swift中进行 segue。 The relevant bit of code is here in LiveController.swift相关的代码位在LiveController.swift

self.performSegue(withIdentifier:"openWelcomePage" ,sender:self)

which throws error:引发错误:

2020-04-16 20:51:44.614413-0400 alpha[53206:2805423] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<alpha.LiveController: 0x101c248c0>) has no segue with identifier 'openWelcomePage''

This indicates the segue has not been named.这表明 segue 尚未命名。 But it has:但它有:

在此处输入图像描述

The over all storyboard is here:全部 storyboard 在这里: 在此处输入图像描述

Note the highlighted NavigationController is the source, it embeds Live which is attached to LiveController.swift .请注意,突出显示的NavigationController是源,它嵌入了Live ,它附加到LiveController.swift The target of the segue is the page with Log in and Sign up . segue 的目标是带有Log inSign up的页面。

Note when I put a button into LiveController and drag a segue from the button to the Welcome view, and name it buttonSegue :请注意,当我将按钮放入LiveController并将 segue 从按钮拖到Welcome视图时,并将其命名为buttonSegue

 self.performSegue(withIdentifier:"buttonSegue" ,sender:self)

displays the page modally as expected.按预期方式显示页面。

You need to have the segue from LiveController, not from Navigation Controller您需要来自 LiveController 的 segue,而不是来自 Navigation Controller

This could be a few things so try these fixes:这可能是一些事情,所以请尝试以下修复:

  1. Clean and build your project.清理并构建您的项目。 Then, run again.然后,再次运行。
  2. Quit Xcode, open up project and run.退出 Xcode,打开项目并运行。
  3. In the Attribute Inspector , remove openWelcomePage and leave it blank.Attribute Inspector中,删除openWelcomePage并将其留空。

Hope that either of these suggestions help.希望这些建议中的任何一个都有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM