iPhone SDK 中找不到新图片

发布于 2024-09-11 02:54:37 字数 433 浏览 1 评论 0原文

我一直在尝试更新与我的应用程序一起打包的图像,但该应用程序拒绝加载新文件。

我最初有一个名为“board.png”的png。然后我创建了一个新文件,它是原始文件的更高分辨率的副本。我从 XCode 的资源组中删除了“board.png”,并以相同的名称添加了新图像。当我运行该应用程序时,仍使用旧的较小图像。

然后,我清理了构建并再次尝试。还是不行。接下来,我将新图像重命名为“BigBoard.png”,并尝试加载该文件名:

 UIImageView* board = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BigBoard.png"]];

但图像根本不加载,即使它位于 Resources 文件夹中。还有其他人有这方面的经验吗?任何帮助将不胜感激。

谢谢!

I've been trying to update an image that is packaged with my app, but the app refuses to load the new file.

I originally had a png called "board.png". I then created a new file which is a higher resolution copy of the original. I deleted "board.png" from the Resources group in XCode and added the new image under the same name. When I run the app, the old, smaller image is still used.

Then, I cleaned the build and tried again. Still doesn't work. Next, I renamed the new image to "BigBoard.png" and tried loading that filename thusly:

 UIImageView* board = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BigBoard.png"]];

but the image does not load at all even though it is in the Resources folder. Does anyone else have any experience with this? Any help would be greatly appreciated.

Thanks!

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

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

发布评论

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

评论(2

愁以何悠 2024-09-18 02:54:37

我现在两次遇到同样的问题。

第一次,当我添加新图像时,我忘记检查“将项目复制到目标组的文件夹”选项,因此当我去构建时图像实际上位于文件夹中。

第二次我需要在再次构建之前清理所有目标(构建 -> 清理所有目标)。这会消除所有预编译的内容并强制 xcode 完全重新编译项目。当我这样做时,构建结果显示了一个额外的操作 CopyPNGFile“path/to/image/image.png”,所以我认为它避免添加新图像,因为它已经在那里看到了它的预编译版本。

看看其中任何一个是否可以修复它。

I had the same problem twice now.

The first time I had just forgotten to check the 'Copy items into destination group's folder' option when I added the new image so the image want actually in the folder when I went to build.

The second time I needed to clean all targets (Build -> Clean All Targets) before I built again. This gets rid of all the precompiled stuff and forces xcode to completely recompile the project. When I did this the build results showed an extra action CopyPNGFile "path/to/image/image.png" so I think it was avoiding adding new image because it saw a precompiled version of it there already.

See if either of those fixes it.

谈情不如逗狗 2024-09-18 02:54:37

我实际上不久前就找到了这个问题的解决方案。由于我将 iPhone 项目转换为 iPad 项目,因此添加到项目中的新文件不会自动添加到 iPad 目标中,也不会出现在 iPad 可执行文件中。为了解决这个问题,我必须通过右键单击文件 -> 手动将文件添加到 iPad 目标。获取信息 ->目标->检查 iPad 目标。

最近的 XCode 更新也解决了这个问题,因此您不再需要手动添加目标。

I actually found the solution to this problem a little while ago. Since I converted my iPhone project into an iPad project, the new files I add to the project were not added automatically to the iPad target and would not be present in the iPad executable. To solve this problem, I had to manually add the files to the iPad target by right clicking the file -> Get Info -> Targets -> Check iPad target.

The recent XCode update also fixes this problem so you no longer have to manually add the targets.

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