如果我将文件名更改为小写,UIImage 仅在 iPhone 上加载

发布于 2024-09-15 14:33:27 字数 487 浏览 3 评论 0原文

我的图像会因按下按钮而发生变化。我的代码设置如下:

UIImage *example = [UIImage imageNamed: @"Example.png"];
UIImage *stuff = [UIImage imageNamed: @"Stuff.png"];
UIImage *bob = [UIImage imageNamed: @"Bob.png"];
UIImage *thing = [UIImage imageNamed: @"thing.png"];

过去,最后一个图像是 Thing.png 而不是 thing.png。这是因为东西会加载到 iPhone 模拟器上,但不会加载到设备上。我在这里看到一个问题说可能是因为iphone文件系统区分大小写,所以我把它改成了小写。然后它就起作用了。我不明白的是,在资源文件夹中它被称为 Thing.png,而不是 thing.png,在 finder 中也是如此。那么为什么需要更改它,特别是如果所有其他图像都加载得很好呢?

I have an image that changes due to a button press. I have the code set up like this:

UIImage *example = [UIImage imageNamed: @"Example.png"];
UIImage *stuff = [UIImage imageNamed: @"Stuff.png"];
UIImage *bob = [UIImage imageNamed: @"Bob.png"];
UIImage *thing = [UIImage imageNamed: @"thing.png"];

It used to be so that the last image was Thing.png and not thing.png. This was because thing would load on iphone simulator but not the device. I saw a question on here that said it may be because the iphone filing system is case sensitive, so I changed it to lowercase. It then worked. What I don't understand is that in the resources folder it is called Thing.png, not thing.png, and it is like that in finder as well. So why did it need to be changed, especially if all the other images loaded just fine?

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

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

发布评论

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

评论(2

二货你真萌 2024-09-22 14:33:27

您是否尝试清理解决方案然后将名称改回来?

Did you try cleaning the solution and then changing the name back?

缺⑴份安定 2024-09-22 14:33:27

当发生类似的情况时,我通常会从手机中删除该应用程序,清理所有目标,清空 XCode 缓存并删除构建文件夹。

在这种情况下,还值得从 Finder 中的项目中删除该文件,然后从 XCode 中删除它(它应该显示为红色),最后重新添加它。

When something like that happens I usually remove the app from the phone, clean all targets, Empty XCode cache and delete the build folder.

In this case it would also be worth deleting the file from the project in Finder, then deleting it from XCode (it should appear red) and finally re-add it.

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