获取项目中包含的图像的文件名 [英] Get file names of images that are included in project

查看:44
本文介绍了获取项目中包含的图像的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Xcode 项目中添加了许多图像:图标、主背景、默认值(用于启动画面)、占位符等.我可以将所有这些图像的名称放入一个数组中吗?

I have added many images to my Xcode project: icons, a main background, default (for splash screen), placeholders, and others. Can I get all these images' names into an array?

推荐答案

这应该返回应用文件夹中所有 png 的数组.

This should return an array of all your pngs in your app folder.

[[NSBundle mainBundle] pathsForResourcesOfType:@"png" inDirectory:nil];

注意* 该数组包含路径.如果您只想要名称在该数组的特定索引上使用 - (NSString *)lastPathComponent,即

Note* The array contains paths. If you just want the name use - (NSString *)lastPathComponent on a specific index of that array, i.e.

NSString *imgName = [[imgArray objectAtIndex:0]lastPathComponent]; //myImage.png

这篇关于获取项目中包含的图像的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆