我想要获取资源文件夹子目录中的所有png文件的数组。 在我的应用程序资源文件夹中,我创建了一个名为“images”的文件夹。这个文件夹包含我需要显示的所有png文件。获取资源文件夹中子目录的路径
这是我试图让路径的方式:
NSString *imagepath = [NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] bundlePath],@"images/"];
NSLog(@"Path to Images: %@", imagepath);
NSArray * paths = [NSBundle pathsForResourcesOfType: @"png" inDirectory:imagepath];
NSMutableArray * allImageNames = [[NSMutableArray alloc] init];
for (NSString * path in paths)
{
if ([[path lastPathComponent] hasPrefix: @"AQ"])
continue;
[allImageNames addObject: [path lastPathComponent]];
}
这样,我得到一个路径像.../appname.app /图像
但是,如果我尝试这样做的,该数组总是空的。 我在做什么错?
格尔茨, Zarak
你是什么形象的名字?他们喜欢'image.AQ'吗? – Nekto
图像名称就像“banana_icon.png”。但是我使用AQGridView创建了所有文件的库。 – DevZarak
那你为什么要检查'[[path lastPathComponent] hasPrefix:@“AQ”]'? – Nekto