即使接口生成器是一个MyClass,我得到一个错误时启动应用程序。

当MyClass是库的一部分时,就会发生这种情况,如果直接在应用程序目标中编译该类则不会发生这种情况。


当前回答

我试过这个,还有这个网站上列出的其他答案,没有一个能帮我理清头绪。以下评论(来自http://www.iphonedevsdk.com/forum/iphone-sdk-development/43330-unknown-class-interface-builder-file.html)有助于:

在搜索、搜索、搜索之后,我终于发现了这个被删除的类的名称隐藏在一个文件中。我必须在X-code中打开界面构建器文件,右键单击它们并选择“查看源代码”。然后我找到了 <object class="NSMutableArray" key="dict.values"> < bool关键= " EncodedWithXMLCoder " >对< / bool > <字符串> com.apple.InterfaceBuilder。IBCocoaTouchP lu gin</string> 这是类名*</string>

不幸的是,简单地删除最后一行并不能解决这个问题,它会抱怨文件中有错误的项数。您需要在它上面的行部分中删除对应的行,它引用CustomClass。

其他回答

I tried most of the solutions you guys suggested above but to no avail. After reading the solution from user776904's I suspected I was having the same issue as I had rebuilt my app from the ground up but copied the xib files from the previous project. I suspected the xib file had a reference to the old project that was causing my error so I simply deleted my mainwindow_ipad.xib file and copied in a new one from a clean new project. This solved it. And I was not game enough to start changing bits of the xib file in its source code.

我有“Interface Builder file中的未知类favoritesbutton”,并将其追踪到一个故事书场景,其中有问题的按钮在身份检查器顶部的class字段中有一个伪自定义类“favoritesbutton”。我想把这个值放在下一个字段:Identity Label。

将其更改为“UIButton”解决了这个问题。

只需在appdelegate applicatoindidfinishlanching方法的开头添加以下代码,就可以正常工作了

(myclass类);

我终于解决了这个问题,我忘记在我的.m文件中添加以下代码:

@implementation MyTableViewCell

@end

所以这是因为我为我的表格单元格做了一个占位符@interface,它有一个连接到.xib文件中的元素,但在Interface Builder中有一个错误,如果没有为一个类指定@implementation,它就找不到它。

我已经完成了从其他论坛查看.xib作为源代码和查看MyTableViewCell的所有步骤,尽管我已经将它注释出了我的代码。我试过重置模拟器。我甚至尝试将所有的类分解为与接口同名的单独文件,但在此之前都不起作用。

附注:根据我的经验,.h/。M文件与@interface的名称不同。我有几个文件包含不止一个@interface,他们工作得很好。

P.P.S.我有一个更详细的解释,为什么UITableViewCell和UICollectionViewCell导致这个错误在https://stackoverflow.com/a/22797318/539149以及如何揭示它在编译时使用registerClass: forCellWithReuseIdentifier:。

只需删除MyClass。M和。h,并将它们再次添加到项目是我的工作。