简体   繁体   English

iPhone开发人员:如何从不同组加载名称相同的图像

[英]iPhone dev: how to load images named the same from different groups

I am working on an iPhone project, and have two themes defined under different directories, with most files share the same names (like background.png, image1.png, image2.png, etc). 我正在研究iPhone项目,并且在不同目录下定义了两个主题,大多数文件使用相同的名称(例如background.png,image1.png,image2.png等)。 I have had them imported into xcode under different group names (group1, group2). 我已经将它们以不同的组名(group1,group2)导入到xcode中。

How do I tell UIImage to load an image from a given group, say, I want group1:background.png? 如何告诉UIImage从给定的组中加载图像,例如,我要group1:background.png?

Thanks, Tim 谢谢,蒂姆

Try this: 尝试这个:

NSString *path = [[NSBundle mainBundle] pathForResource:@"image1" ofType:@"png" inDirectory:@"group1"];
[UIImage imageWithContentsOfFile: path];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM