我没有显示任何图像,只显示文件名。
目前即时使用此代码:
NSString *filePath = [[self documentsPath] stringByAppendingPathComponent:@""];
NSFileManager *imagesFileManager = [NSFileManager defaultManager];
imagesArr = [[imagesFileManager contentsOfDirectoryAtPath:filePath error:nil]filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self ENDSWITH '.jpg'"]];
arryList = [[NSMutableArray alloc] initWithArray:[imagesArr copy]];//display text
imagesList = [[NSMutableArray alloc]init];//display image
for (NSString *anImage in arryList) {
anImage = [NSString stringWithFormat:@"Documents/%@",anImage];
[imagesList addObject:anImage];
}
答案 0 :(得分:2)
在for
循环中,您只是将文件路径添加到数组而不是UIImage。
更改for循环,如下所示:
NSString *docPath = [self documentsPath];
for (NSString *anImagePath in arryList) {
anImagePath = [NSString stringWithFormat:@"%@/%@",docPath,anImagePath];
UIImage *image = [UIImage imageWithContentsOfFile:anImagePath];
if ( image )
[imagesList addObject:image];
}