Hey.
I have a tableView in my app that I load in images to from the NSDocumentDirectory. It works, but when scrolling up and down, the app seems to freeze a bit. I know that this is because of the images getting loaded in, and not getting cached, but I don't know how I can load them in later, after they've been created.
The images are .png-s, 10kB to 50kB big and 300*127 in size.
I am currently loading them in with this code:
imagesPath = [NSString stringWithFormat:@"%@/images/", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]];
if ([fileManager fileExistsAtPath:[imagesPath stringByAppendingPathComponent:[NSString stringWithFormat:@"/%d.png", rowID]]]) {
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[imagesPath stringByAppendingPathComponent:[NSString stringWithFormat:@"/%d.png", rowID]]];
// If image contains anything, set cellImage to image. If image is empty, use default, noimage.png.
if (image != nil){
// If image != nil, set cellImage to that image
cell.cellImage.image = image;
}
[image release];
image = nil;
}