在 iPhone 程序中加载初始笔尖时出现问题

发布于 2024-10-14 16:45:09 字数 972 浏览 2 评论 0原文

我遇到的问题与此线程中讨论的问题类似 ,但提供给他的解决方案对我不起作用。我为冗长的描述表示歉意,但这是我关于 SO 的第一篇文章,我希望完整。

我有一个在模拟器中运行良好的程序。但是,当我尝试将其推送到设备时,我收到一条错误,内容如下:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/....app> (loaded)' with name 'MainWindow''

所以:它正在尝试加载名为 MainWindow 的 XIB,但找不到它。那是因为我没有一个名为 MainWindow 的 XIB;我加载的第一个 XIB 称为 FrontPage.xib。我没有使用其中一个模板启动该程序,因此一开始就没有提供 MainWindow.xib 文件。

Google 机器告诉我可以在我的应用程序的 plist 中修改 Main nib 文件基本名称。所以,我去那里并将其更改为 FrontPage。现在,我得到了一个不同的错误:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x12c270> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'

我在这里把头发拉出来 - 有人知道解决方案吗?

I'm having a problem similar to the one discussed in this thread, but the solution provided to him isn't working for me. I apologize for the lengthy description, but this is my first post on SO and I want to be complete.

I have a program that runs fine in the simulator. However, when I try to push it out to the device, I get an error that says this:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/....app> (loaded)' with name 'MainWindow''

So: it's trying to load a XIB called MainWindow, but it can't find it. That's because I don't have a XIB called MainWindow; the first XIB I load is called FrontPage.xib. I didn't start this program using one of the templates and thus was not provided with a MainWindow.xib file at the beginning.

The Google machine tells me that the Main nib file base name can be modified in my app's plist. So, I go there and I change it to FrontPage. Now, I get a different error:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x12c270> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'

I'm pulling my hair out over here - anyone know a solution?

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

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

发布评论

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

评论(3

入画浅相思 2024-10-21 16:45:09

确保您的视图已连接到 Interface Builder 中的“View”插座。您可以通过右键单击 IB 中的“文件所有者”,然后将其拖至视图的“视图”出口来完成此操作。这是我正在制作的游戏的插图。注意从右侧的点拖到“视图”的蓝线。

在此处输入图像描述

您需要检查的另一件事是 Info.plist。确保您已将 nib 文件命名为 FrontPage,而不是 *FrontPage****.nib***。

Make sure that your view is connected to your "View" outlet in Interface Builder. You do this by right clicking on your "File's Owner" in IB and then dragging to the "View" outlet to your View. Here's an illustration from a game I'm working on. Notice the blue line, dragged from the dot on the right to the "view".

enter image description here

Another thing you will want to check is your Info.plist. Make sure that you have called your nib file FrontPage and not *FrontPage****.nib***.

鸠书 2024-10-21 16:45:09

如果 Frontpage.xib 将成为应用程序的主 xib,那么您必须在该 xib 中创建一个 Window 对象和一个 App Delegate 对象,以便能够加载应用程序。在开始呈现视图控制器等之前,您必须配置应用程序和窗口,否则它将像您所描述的那样崩溃。我建议使用基于 Window 的模板创建一个新项目,然后查看自动创建的 MainWindow.xib,并尝试在 Frontpage.xib 中模仿它......

尽管我真诚地建议使用 MainWindow。 sib 在您的项目中并使您的 Frontpage.xib 成为普通视图控制器 xib。如果您选择向项目添加新文件,然后选择“用户界面”,然后选择“应用程序 xib”而不是“查看 xib”,那么它将为您设置接近您需要的内容。

项目模板非常重要且有用。您应该始终使用它们。我的一切都是从基于 Window 的模板开始的。它是最基本的模板,也是最灵活的。

If Frontpage.xib is going to be your application's main xib, then you have to create a Window object and an App Delegate object in that xib in order for the app to be able to load. Before you can start presenting view controllers and such you have to configure the app and the window or it will crash as you describe. I would suggest creating a new project using a Window based template and just take a look at the MainWindow.xib that gets created automatically and try to mimic it in your Frontpage.xib..

.. Although I would just sincerely suggest using a MainWindow.sib in your project and making your Frontpage.xib a normal view controller xib. If you choose to add a new file to your project, then choose User Interface, then choose Application xib instead of View xib, then it will set you up with something close to what you need.

The project templates are important and useful. You should always use them. I start all of mine with a Window Based template. It is the most basic template and the most flexible.

眼前雾蒙蒙 2024-10-21 16:45:09

如果通过 IB 设置文件所有者属性来正确设置 FrontPage.xib 的视图控制器,那么您还需要设置视图属性。您可以通过控制从 Fileowner 拖动到视图来完成此操作。从错误来看,您似乎尚未设置视图的视图属性。在 Interface builder 中打开 nib,然后在连接 Inspector 中查找 View Connection,这必须连接到文件所有者的视图出口。您无需在任何地方将其声明为财产。

If the view controller for FrontPage.xib is set properly by setting the File owner property via IB then you also need to set the view property. you can do this by control dragging from Fileowner to the view. From the error it appears that you have yet not set the view property for your view. Open the nib in Interface builder and and look for the View Connection in connection Inspector , this must be connected to file owner's view outlet. You don't need to declare it as a property anywhere.

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