我的 Storyboard 中的两个 ViewController 之间有一段表演转场。当调用 performSegueWithIdentifier:
时,我得到一个 NSInvalidArgumentException
:
Receiver (<[MY VIEWCONTROLLER SUBCLASS]: 0x7fc9e99f0640>) has no segue with identifier 'HomeToSettings''
segue 肯定存在并已连接,并且在同源 ViewController 上还有许多其他 segue 可以正常工作。
在 Storyboard的源代码中,segue 就像所有工作的一样出现:
<connections>
<outlet property="notificationsButton" destination="hG9-8E-sv6" id="mn0-1x-Qxj"/>
<outlet property="settingsButton" destination="Fy0-au-d6J" id="r1c-fG-KOP"/>
<outlet property="tableView" destination="9bJ-Cd-hc3" id="Wuy-hJ-QVU"/>
<segue destination="ad8-yH-D5h" kind="show" identifier="HomeToCreateList" id="bsg-J2-Gp3"/>
//More segues...
<segue destination="pNX-Jw-wau" kind="show" identifier="HomeToNotifications" id="B2t-BE-YpW"/>
<segue destination="xge-ah-WXM" kind="show" identifier="HomeToSettings" id="nTa-qO-SCb"/>
</connections>
我试过:
- 重命名 Storyboard
- 删除并重新创建 segue
- 重命名 segue
- 清理项目
- 重新安装应用
- 重置模拟器上的内容和设置
- 物理设备
Xcode 和 iOS 是截至 2016 年 6 月 1 日的最新版本。
如果它在某种程度上很重要,我将通过附加到 UIBarButtonItem 的 IBAction 触发 segue。然而,从另一个 UIBarButtonItem 到另一个 ViewController 的另一个 segue 工作得很好。
我调用 segue 的确切行是:
[self performSegueWithIdentifier:@"HomeToSettings" sender:self];
我真的迷路了。
最佳答案
例如你有 show segue
名为 HomeToSettings
来自 VC-A to VC-B
那么你只能调用[self performSegueWithIdentifier:@"HomeToSettings" sender:self];
仅来自 VC-A
.
如果您尝试从其他 Controller 调用,则会报错。
我刚刚复制了你的声明 [self performSegueWithIdentifier:@"HomeToSettings" sender:self];
我在 H
之前发现了一个奇怪的字符你的HomeToSettings
字符串。
可以通过键盘左方向键或退格键查看!!
性格看起来像
因此,请将其从设置此标识符的所有位置移除。
从下面的语句中复制标识符并使用它在界面构建器中设置并使用下面的语句执行 segue。
[self performSegueWithIdentifier:@"HomeToSettings" sender:self];
希望这会有所帮助:)
关于ios - Storyboard 认为 Segue 不存在。但确实如此,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37561945/