ios - Storyboard 认为 Segue 不存在。但确实如此

标签 ios objective-c xcode uistoryboard uistoryboardsegue

我的 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字符串。

可以通过键盘左方向键或退格键查看!!

性格看起来像

enter image description here

因此,请将其从设置此标识符的所有位置移除。

从下面的语句中复制标识符并使​​用它在界面构建器中设置并使用下面的语句执行 segue。

  [self performSegueWithIdentifier:@"HomeToSettings" sender:self];

希望这会有所帮助:)

关于ios - Storyboard 认为 Segue 不存在。但确实如此,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37561945/

相关文章:

ios - 如何像 uipickerview 中的其他行一样对齐选定的行

ios - 动态原型(prototype)选项未出现在属性检查器中

ios - 将字典对象附加到 UITableViewCell

ios - 在 XCode 上运行 FaceSubStitution 和 ScrambleSuit

ios - WKInterfaceTable 渲染问题。滚动条和最后一行都被切断

ios - entry.remove(success, fail) 调用成功,但不删除图像

ios - Xcode 非公开 API

iphone - 在 xcode 4.3 beta 上为设备配置 PLCrashReporter 框架

objective-c - 无法在其他 View Controller 中访问我的数组

objective-c - 是否有任何关于使用 ARC 的性能影响的具体研究?