How to load images from a specific group?

女生的网名这么多〃 提交于 2019-12-10 12:26:15

问题


In Xcode4, I use groups for grouping my stuff, for example I have a tree like group hierarchy for my various images. The interesting part is that I can access an image directly without specifying a group.

UIImage *img = [UIImage imageWithName:@"image1.png"];

I have two questions. First, how to define concrete path of groups where resides all needed images (for example for the group tree "Img/Enemy/")? And a second, how to iterate through that group path to load all the images from that group? IMHO groups are related to bundles but I found them very confusing :(


回答1:


When you use groups, you are not actually creating folders, so when you build your app everything is put at the root of the bundle. This is why you can access them without specifying the group name. If you want to use folders, you can create folders in Finder and add them to the project (make sure to check "create folder references for any added folders"!).




回答2:


Groups are only used to organize file within Xcode; they are not really of any use outside of Xcode, nor does Xcode copy them over to the final app.

You need to use folder references instead of groups to do what you want.



来源:https://stackoverflow.com/questions/6522833/how-to-load-images-from-a-specific-group

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!