[英]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 in
和Sign 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:这可能是一些事情,所以请尝试以下修复:
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.