iphone - 接收器(<ViewController :>) has no segue with identifier - initiating segue from a scene

标签 iphone xcode uiviewcontroller sprite-kit segue

在查看了很多相关问题并尝试了所有问题之后,我发布了自己的问题,试图获得满意的答复。

我的应用程序从基础 ViewController 开始,然后使用 Storyboard中创建的按钮的模态转场过渡到 GameScene ViewController,然后呈现游戏场景。游戏结束后,我以编程方式创建按钮以从 GameScene 导航回基本 ViewController。当按下此按钮时,以下代码会尝试返回到基本 ViewController:

UIViewController *vc = self.view.window.rootViewController;
[vc performSegueWithIdentifier:@"BackToStartScreenSegue" sender:nil];

它调用的segue是通过从GameSceneViewController按住control拖动到基础ViewController并选择modal作为segue类型来创建的。这会创建一个奇怪的 8 字形模式,其中每个 View Controller 都有一个指向另一个 View Controller 的模态转场。我怀疑这不是最佳的。

我有一种感觉,我应该使用展开转场,但我不确定。我尝试向 GameSceneViewController Storyboard添加一个按钮,然后在游戏结束后启用它,但我无法控制是否通过我的场景启用它,但我可能做得不对。

确切的错误消息如下:* 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“Receiver () 没有带有标识符“BackToStartScreenSegue”的 segue”

我还检查并仔细检查了 Segue 标识符的拼写是否正确,并从模拟器和测试设备中删除了该应用程序,并用它再次进行了清理和构建。

最佳答案

由于它是模态转场,您是否尝试过使用

[self dismissViewControllerAnimated:YES completion:nil];

关于iphone - 接收器(<ViewController :>) has no segue with identifier - initiating segue from a scene,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24400349/

相关文章:

iphone 输入类型(带两位小数的数字)

iphone - UINavigationController + UITableViewController 横向方向的反向转换错误

ios - 从 viewcontroller 移动到 VC 时崩溃

ios - Realm 无法在后台线程中解密数据库错误

xcode - NSDistributedNotificationCenter 的可用通知

iphone - 使用 UIPopoverController 时出错

ios - 提交到App Store问题:不支持的体系结构x86

ios - Facebook 登录完成后的 UITableView reloadData()

iOS 取消模态呈现的导航 Controller

ios - 我如何从 UINavigationController 转到 UIViewController