iPhone Interface Builder - 将资源移至子目录,现在 IB 看不到它们!

发布于 2024-08-12 16:49:07 字数 349 浏览 5 评论 0原文

我的 Xcode 项目中有一堆图像。它们最初是在没有选择“为任何添加的文件夹创建文件夹引用”的情况下添加的。因此,我删除了引用并按照这些说明重新添加 包含资源不幸

的是,Interface Builder 不会显示该目录中的任何图像。在项目树上,目录出现一个蓝色图标,所有文件都在那里!

文件名显示在 IB 检查器中(即在“图像”属性下),但我缺少该目录中所有内容的图像图标。

有什么想法如何让图像再次显示吗?

I had a bunch of images in my Xcode project. They were originally added without choosing "Create Folder References for any added folders". So I removed the references and re-added as per these instructions Include a resource directory hierarchy into app bundle

Unfortunately, Interface Builder will not display any of the images inside that directory. On the project tree the directory comes up with a blue icon and all the files are there!

The file names show in the IB Inspector (i.e. under the 'Image' property), but I get missing image icons for everything located in that directory.

Any ideas how to get the images showing again?

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

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

发布评论

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

评论(3

烟─花易冷 2024-08-19 16:49:07

问题解决了!事实证明,蓝色文件夹引用没问题,但 IB 不会阅读它们!
对于任何其他想知道的人,如果您有以下内容:

/iphone-project-dir/images/pic.png

一旦您将它们添加到 Xcode 中的蓝色文件夹中(如上面的链接中详细介绍),您可以在 IB 中引用它们,如下所示:

images/pic.png

在 XIB 的 XML 中,它将看起来像这样

<string key="NSResourceName">images/pic.png</string>

简单!唯一的缺点是 Interface Builder 的所见即所得预览不处理这些路径!

我在这里找到了答案 http://www.iphonedevsdk.com/forum/iphone-sdk-development/6457-xcode-folder-directories.html iphonedevsdk.com/forum/iphone-sdk-development/6457-xcode-folder-directories.html

Problem solved! Turns out that blue folder references are fine, but IB will not read them!
For anyone else who cares to know, if you have the following:

/iphone-project-dir/images/pic.png

Once you've added them in a blue folder in Xcode (as detailed in link above), you can refer to them in IB as follows:

images/pic.png

In the XIB's XML it will look something like this

<string key="NSResourceName">images/pic.png</string>

Simple! The only drawback is Interface Builder's WYSIWYG preview does not process these paths!

I found the answer here http://www.iphonedevsdk.com/forum/iphone-sdk-development/6457-xcode-folder-directories.html

烂柯人 2024-08-19 16:49:07

如果您希望在 SCM 和 XCode 下构建图像,但实际上并不介意在构建最终的 .ipa 包后所有图像都将放置在一个目录中,那么您需要执行以下操作:

  • 创建一个名为 例如 的目录根文件夹中的“Images”
  • 将所有图像放入此文件夹
  • 从 XCode 中添加一个新组并将其命名为“Images”
  • 右键单击​​该组并选择“将文件添加到...”
  • 选择所有文件并取消选中“将项目复制到目标组的文件夹中”,因为它们已经在其中
  • 确保选择正确的目标

现在,您可以从 Interface Builder 中选择图像,而无需在其前面添加文件夹名称前缀,并且您将在 Interface Builder 中看到图像的预览。

在设计应用程序时,为我提供 IB 预览和整洁的文件夹结构。

If you like to have your images structured in your SCM and under XCode but really doesn't mind that all images will be placed in one directory once building the final .ipa package, here is what you need to do:

  • Create a directory called e.g. "Images" in your root folder
  • Place all your images into this folder
  • Add a new group from within XCode and call this "Images" too
  • Right-click this group and choose "Add Files to ..."
  • Select all your files and uncheck "Copy items into destination group's folder" because they are already in there
  • Make sure to select your right targets

From Interface Builder you are now able to pick your images without prefixing it with the folder name and you will see a preview of your images within Interface Builder.

Gives me both my IB preview and a neat folder structure when designing my app.

疯狂的代价 2024-08-19 16:49:07
  1. 将 Images 文件夹复制到您的项目文件夹。
  2. 将此文件夹添加到项目中。在“选择添加这些文件的选项”对话框中,您必须选中“创建组”。
  3. “如果需要,复制项目”您可以选中。
  4. 确保选择正确的目标
    结束
  1. Copy Images folder to your project folder.
  2. Add this folder to project. In "Choose options for adding these files" dialog, you must check "Create groups".
  3. "Copy items if needed" you can leave checked.
  4. Make sure to select your right targets
    Finish
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文