I m using SDWebImage
to cache image. But its not working. I am using it in this fashion under cellForRowAtIndexPath
:
[cell.image sd_setImageWithURL:[NSURL URLWithString:[NSMutableString stringWithFormat:@"%@app/media/access/pictures?p=%@",baseurl,data.picPath]]
placeholderImage:[UIImage sd_animatedGIFNamed:@"image_loader.gif"] options:SDWebImageRefreshCached];
I suppose its downloading the images asynchronously. But my app freezes while scrolling the UITableView
. And there is also network usage while scrolling up, for me that shouldn't happen as I am caching it.
Besides I have some logic to resize UIImageView
frame according to image size under heightForRowAtIndexPath
, could that be any reason???
if(data.type == 2)
{
height = 260.00;
}
else if(data.type == 1)
{
height = self.view.frame.size.width/2 + 115;
}
else
{
NSString *filePath = [NSString stringWithFormat:@"%@app/media/access/pictures?p=%@",baseurl,data.picPath];
self.img = [UIImage imageWithData: [NSData dataWithContentsOfURL:[NSURL URLWithString:filePath]]];
if (self.img.size.width > CGRectGetWidth(self.view.bounds)) {
CGFloat ratio = self.img.size.height / self.img.size.width;
return CGRectGetWidth(self.view.bounds) * ratio+120;
} else {
return self.img.size.height+110;
}
}