I have created a tableView with customCell which has three images in every row.I have loaded images from folder. When I scroll up or down tableView takes time to move up or down. I found some concepts like cache and lazy loading which are loaded images from server. I do not know how to use it in my app.
ImagesClass *Obj1 = [imageLists objectAtIndex:indexPath.row*noOfImageInRow];
UIImage *image1 = [self getImageForImageId:Obj1.imageId FromPath:SAVEDIMAGE_DIR];
Obj1.thumbImage = [self imageWithImage:image1 convertToSize:CGSizeMake(130, 130)];
[cell setImage:1 :Obj1.thumbImage RowNo:indexPath.row*noOfImageInRow];
}
if ([imageLists count] > indexPath.row*noOfImageInRow+1) {
ImagesClass *Obj2 = [imageLists objectAtIndex:indexPath.row*noOfImageInRow+1];
UIImage *image1 = [self getImageForImageId:Obj2.imageId FromPath:SAVEDIMAGE_DIR];
Obj2.thumbImage = [self imageWithImage:image1 convertToSize:CGSizeMake(130, 130)];
[cell setImage:2 :Obj2.thumbImage RowNo:indexPath.row*noOfImageInRow+1];
}
if ([imageLists count] > indexPath.row*noOfImageInRow+2) {
ImagesClass *Obj3 = [imageLists objectAtIndex:indexPath.row*noOfImageInRow+2];
UIImage *image1 = [self getImageForImageId:Obj3.imageId FromPath:SAVEDIMAGE_DIR];
Obj3.thumbImage = [self imageWithImage:image1 convertToSize:CGSizeMake(130, 130)];
[cell setImage:3 :Obj3.thumbImage RowNo:indexPath.row*noOfImageInRow+2];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.delegate = self;
return cell;
Sometimes ago I have done this. My experience is, whether you load from folder or net, you have to save the thumbnail copy locally. Then it will be faster to load.
For every image I saved a thumbnail copy in a /thumbnail folder. If for some image there is no thumbnail, I store one then load them.
By this way, the table cell load the images faster.