iphone - UIImage imageNamed : does not find image within blue referenced Xcode-folder

标签 iphone ios xcode cocoa-touch

在我的 Xcode 项目中,我有一个蓝色引用文件夹,它指向一个包含图像的文件夹。

蓝色文件夹的好处是我不必手动将文件添加到 Xcode。 因此,当我将新图像添加到文件夹时,它会自动显示在 Xcode 中,但是,当我尝试使用代码从代码中引用该文件时

[UIImage imageNamed:@"myFileFromTheBlueFolder"];

尽管将顶级文件夹添加到目标,但它没有找到图像。 :-(

当我来自一个蓝色文件夹时,我是否必须以不同的方式引用图像,恕我直言,这将完全破坏拥有这样一个文件夹的目的。

最佳答案

Kevin 关于 +[UIImage imageNamed:] 提供的内存优化是正确的,但绝对可以访问蓝色文件夹(文件夹引用)中的图像。您所要做的就是将文件夹名称添加到图像名称中。例如:

你的资源是这样组织的:

Icons (blue folder / folder reference)
  |__camera.png
  |__checkmark.png
Shared (yellow folder / xcode group)
  |__back.png
  |__logo.png

您可以像这样访问图像:

[UIImage imageNamed:@"Icons/camera"];
[UIImage imageNamed:@"Icons/checkmark"];

[UIImage imageNamed:@"back"];
[UIImage imageNamed:@"logo"];

关于iphone - UIImage imageNamed : does not find image within blue referenced Xcode-folder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11499925/

相关文章:

ios - 使用 componentsSeparatedByString() 断点

ios - Simperium共享公用数据集

ios - 永远重复显示标签中的文本数组

ios - 未解析的标识符 - SKErrorPaymentCancelled

android - 在移动应用程序中使用分析有哪些道德问题?

ios - 只要按下键盘上的 x 按钮,如何从一个文本字段中删除另一个文本字段中的值

ios - 集成 Nuance Dragon Mobile 时架构 x86_64 的 undefined symbol

iphone - 在后台获取核心数据

iphone - 在导航 Controller 中添加选项卡栏 Controller 时隐藏后退按钮

javascript - iPhone UIAutomation 按钮点击不触发