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

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

问题描述

对于 iOS 应用,我有一个故事板和多个控制器,以及从控制器 GameClass 到控制器 SettingsClass 的转场.视图控制器 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''

我尝试了在其他文章中找到的许多技巧(例如重命名情节提要、清理项目、更改模拟器格式、为转场赋予另一个名称等),但问题不断出现.

我在这里上传了我的代码版本:http://www.petits-suisses.ch/问题.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

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

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