简体   繁体   English

将项目从情节提要更改为Xib文件时,出现“此类不符合键的键值编码”错误

[英]“This class is not key value coding-compliant for the key” error when changing project from storyboard to xib files

I had lots of progress in a project which started using both storyboards and xib files. 我在一个开始使用情节提要和Xib文件的项目中取得了很大的进步。 Then I decided to change it all to xib files so that firmwares older than 5.0 could use them. 然后,我决定将所有内容都更改为xib文件,以便早于5.0的固件可以使用它们。 I had some trouble doing that so I created a new project and began copying all of the code and content of the xib files. 我在执行此操作时遇到了一些麻烦,因此我创建了一个新项目,并开始复制xib文件的所有代码和内容。 However, when I ran the project, the debugger gave me the error "This class is not key value coding-compliant for the key gameStarts"(name of an outlet). 但是,当我运行该项目时,调试器给我一个错误“该类与键gameStarts的键值编码不兼容”(插座名称)。 I already tried cleaning all targets from the DerivedData folder, resetting my iOS simulator, and checking in the connections inspector of the designated xib file for rare outlets, but nothing seems to work. 我已经尝试从DerivedData文件夹中清除所有目标,重置我的iOS模拟器,并检查指定的xib文件的连接检查器中的罕见出口,但是似乎没有任何效果。 I have searched for hours without success. 我搜索了数小时却没有成功。 Help would be appreciated. 帮助将不胜感激。

It seems that the .xib file has a outlet reference to gameStarts, but in the controller file, there isn't a IBOutlet property gameStarts. .xib文件似乎具有对gameStarts的出口引用,但是在控制器文件中,没有IBOutlet属性gameStarts。 The most easy way to check whether you have set it properly in xCode 4 is switching to the xib file, selected the file's owner, click on the triangle on the right of the class name. 检查您是否已在xCode 4中正确设置它的最简单方法是切换到xib文件,选择文件的所有者,然后单击类名称右侧的三角形。 This should bring you to the class file. 这应该带您到类文件。 I met similar problems before, they were caused by the incorrect reference. 我之前遇到过类似的问题,它们是由不正确的引用引起的。

And also find the element which is connected to gameStarts in xib file, re-connect it to your controller. 并在xib文件中找到连接到gameStarts的元素,然后将其重新连接到您的控制器。 I guess you would have copied the interface from storyboard file. 我想您应该从情节提要文件中复制界面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 删除情节提要并使用Xib会生成错误“类不符合键的键值编码要求” - Deleting Storyboard and using Xib generates error “class is not key value coding-compliant for the key” “此类不符合密钥的键值编码标准……” - “this class is not key value coding-compliant for the key…” 获取错误类不是密钥值的密钥值编码兼容 - Getting error class is not key value coding-compliant for the key name 此类不符合键的键值编码标准[Tableview错误] - this class is not key value coding-compliant for the key [Tableview error] 错误:此类不是密钥keyPath的密钥值编码兼容 - Error: This class is not key value coding-compliant for the key keyPath NSObject类的键值编码兼容? - key value coding-compliant for NSObject class? 此类不是键值编码兼容的 - This class is not a key value coding-compliant iOS - 使用关联时“此类不符合键值编码”? - iOS - “This class is not key value coding-compliant” when using associations? 空项目时发生错误:“此类不符合ViewController的键值编码标准。” - Error on empty project: “this class is not key value coding-compliant for the viewcontroller.” 来自XIB的新自定义单元格导致密钥值符合密钥...? - New custom cell from XIB causing key value coding-compliant for the key …?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM