gpt4 book ai didi

iphone - (iphone) imageNamed 当有多个同名文件时?

转载 作者:行者123 更新时间:2023-12-03 18:39:04 25 4
gpt4 key购买 nike

正如问题所述,当资源目录下有多个具有给定名称的文件时,imageNamed 如何工作?

有没有办法区分两个具有相同名称(但路径不同)的不同文件?

谢谢

最佳答案

任何 Xcode 包中的文件夹都是“组”。也就是说,它们不是实际的目录。这些组中的文件仍然位于 bundle 的根目录中。

因此,应用程序包中不可能有两个(或更多)同名文件。

参见:http://majicjungle.com/blog/?p=123

群组的问题:

The directory structure is lost when it’s copied to the iphone app, and so inside your app bundle is just a big list of all your resources in the base directory. As a result of this, duplicate filenames become an issue. If any files within your directory structure on disk contain the same filename, the build process silently screws everything up. It appears to be ‘first in wins’, with only one of the resources making it into the app bundle. So it’s no good if you have a bunch of different level packages each containing a different ‘Terrain.png’ file.

如果您通过创建文件夹引用来维护目录结构,则可以消除重复文件名的问题。然而,检索文件是个问题。

你可以做的是使用 NSBundle 类:

[[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:@"path/to/file.jpg"]

关于iphone - (iphone) imageNamed 当有多个同名文件时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4581666/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com