(iphone) imageNamed 当有多个同名文件时?
正如问题所说,当资源目录下有多个具有给定名称的文件时,imageNamed 如何工作?
有没有办法区分两个具有相同名称(但路径不同)的不同文件?
谢谢
as question says, How does imageNamed work when there are multiple files with the given name under the resource directory?
Is there a way to differentiate two different files with same name (but different path)?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
任何 Xcode 包中的文件夹都是“组”。也就是说,它们不是实际的目录。这些组中的文件仍然位于捆绑包的根目录中。
因此,应用程序包中不可能有两个(或更多)同名文件。
请参阅:http://majicjungle.com/blog/?p=123
群组问题:
如果通过创建文件夹引用来维护目录结构,则可以消除重复文件名的问题。然而,检索文件是一个问题。
你可以做的是使用 NSBundle 类:
The folders in any Xcode bundle are "groups". That is, they are not actual directories. The files in those groups are still located in the bundle's root.
So, having two (or more) files with the same name in the app bundle is impossible.
See: http://majicjungle.com/blog/?p=123
The problem with Groups:
If you maintain your directory structure by creating folder references, this eliminates the problem of duplicate file names. However, retrieving the files is the problem.
What you can do is use the NSBundle class: