Interface Builder 文件中的未知类 myView

发布于 2024-12-03 14:59:37 字数 1589 浏览 3 评论 0原文

我想以不同于 .h 和 .m 文件的方式命名我的笔尖。我认为视图只是一个视图。所以我不明白为什么“控制器”应该出现在似乎是惯例的名称中。当我这样做并确保委托、视图等设置正确时,我在加载 myView.xib 时收到以下运行时警告;然而,一切都按预期进行。我不喜欢让警告挥之不去。我该如何摆脱它?

 Unknown class myView in Interface Builder file

myView.xib

<object class="NSMutableArray" key="dict.values">
    <bool key="EncodedWithXMLCoder">YES</bool>
    <string>myViewController</string>
    <string>UIResponder</string>
    <string>myView</string>

myViewController.h/m

@interface myViewController 

我已查看此错误的所有相关线程,但没有一个答案或场景 100% 匹配。

参考: Interface Builder 文件中的未知类 MyOldClass - 在我的例子中, grep 会显示我确实有对 myView 的引用。如果我将其重命名为 myViewController,我会得到以下内容:

 -[myViewController _setViewDelegate:]: unrecognized selector sent to instance 0x186550
 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[myViewController _setViewDelegate:]: unrecognized selector sent to instance 0x186550'

参考: “Interface Builder 文件中的未知类”运行时出错

我在这个线程上尝试了一些想法,但它不起作用。 -all_load -ObjC 标志无法解决该错误。 KeepAlive 也不会被破解。

但是,我不认为这是链接错误。 myView 类存在于 nib 的上下文中。所以这将是一个运行时动态加载问题。另外,myView 确实存在。这是笔尖中的视图。

我是否应该承认并让我的 nib 文件与 .m 和 .h 文件具有相同的文件名? 有什么想法吗?

TX

I wanted to name my nib differently from my .h and .m files. I think of the view as just that, a view. So I don't see why 'Controller' should be in the name which seems to be the convention. When I do this and make sure that the delegates, views, etc. are set correctly, I get the following runtime warning when I load myView.xib; however, everything runs as expected. I don't like to leave warnings lingering. How do I get rid of it?

 Unknown class myView in Interface Builder file

myView.xib

<object class="NSMutableArray" key="dict.values">
    <bool key="EncodedWithXMLCoder">YES</bool>
    <string>myViewController</string>
    <string>UIResponder</string>
    <string>myView</string>

myViewController.h/m

@interface myViewController 

I have looked through all of the related threads on this error and none of the answers or scenarios 100% match.

Reference:
Unknown class MyOldClass in Interface Builder file -- in my case, the grep would show that I do have a reference to myView. If I rename this to myViewController I get the following:

 -[myViewController _setViewDelegate:]: unrecognized selector sent to instance 0x186550
 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[myViewController _setViewDelegate:]: unrecognized selector sent to instance 0x186550'

Reference:
"Unknown class <MyClass> in Interface Builder file" error at runtime

I played with ideas on this thread and it did not work. -all_load -ObjC flags don't resolve the error. Nor does the KeepAlive hack.

However, I don't think this is a link error. The class myView exists in context of the nib. So this would be a runtime dynamic loading issue. Also, myView does exist. It is the view in the nib.

Should I just conceded and make my nib file have the same filename as .m and .h files?
Any thoughts?

tx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

攒一口袋星星 2024-12-10 14:59:37

您可以查看我的解决方案在此线程中,我仔细检查了我的所有类是否在其 .m 文件中指定了相应的 @implementation。

You might take a look at my solution in this thread, I double checked that all of my classes have a corresponding @implementation specified in their .m files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文