当标识符存在时,“Receiver没有带标识符的segue” [英] 'Receiver has no segue with identifier' when identifier exists

查看:369
本文介绍了当标识符存在时,“Receiver没有带标识符的segue”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于iOS应用程序,我有一个故事板和多个控制器,以及从控制器 GameClass 到控制器 SettingsClass 的segue。在控制器 GameClass 中的segue有一个名为 GameToSettings 的标识符:


For an iOS app, I have a story board and multiple controllers, and a segue going from controller GameClass to controller SettingsClass. The segue, in view Controller GameClass has an identifier called GameToSettings:

但是,当我想从我的 GameClass 中调用segue:

However, when I want to call the segue from my GameClass:

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

我收到错误消息

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<GameClass: 0xcf0c550>) has no segue with identifier 'GameToSettings''

我尝试了很多其他文章中的提示(比如重命名故事板,清理项目,更改模拟器格式,给segue另一个名字) ,),但问题仍然存在。


我在这里上传了我的代码版本: http://www.petits-suisses.ch/Issue.zip
我可以继续尝试的任何建议吗?
谢谢。

I tried many tips I found in other articles (like renaming the storyboard, cleaning the project, changing simulator format, giving another name to the segue, ), but the issue keeps coming.

I've uploaded a version of my code here: http://www.petits-suisses.ch/Issue.zip. Any suggestion of what I could continue trying ?
Thanks.

推荐答案

你不应该实例化你的视图控制器这样:

You should not instantiate your view controller this way:

GameClass *myNewVC = [[GameClass alloc] init];

相反,请使用

 [[UIStoryboard storyboardWithName:@"storyboard name" bundle:nil] instantiateViewControllerWithIdentifier:@"vc identifier">]

编辑:
查看 https:// github.com/mac-cain13/R.swift

它允许您使用自动完成轻松实例化,类型安全的方法: R.storyboard.main.myViewController

It will allow you to instantiate it easily with autocompletion, type safe method: R.storyboard.main.myViewController

这篇关于当标识符存在时,“Receiver没有带标识符的segue”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆