Reputation: 3
I didnt get any images displayed, only the filename is shown.
Currently im using this codes:
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];
}
Upvotes: 0
Views: 183
Reputation: 17478
In the for
loop , you are just adding the file path to the array instead of UIImage.
Change the for loop as follows:
NSString *docPath = [self documentsPath];
for (NSString *anImagePath in arryList) {
anImagePath = [NSString stringWithFormat:@"%@/%@",docPath,anImagePath];
UIImage *image = [UIImage imageWithContentsOfFile:anImagePath];
if ( image )
[imagesList addObject:image];
}
Upvotes: 2