im making a tableview loaded with some NSArrays, the cell contains two labels and a background image view loaded with a URL image. The problem is that the scrolling of the table
You are calling [NSData dataWithContentsOfURL:[NSURL URLWithString:_ImageUrl[row]]]
from cellForRowAtIndexPath
, which is not good idea. Because it'll go to the server every time a UITableViewCell
is loaded.
You must use Asynchronous image loading & cache. These libraries might help you : (My personal favourite is SDWebImage
)
1) https://github.com/rs/SDWebImage
2) https://github.com/nicklockwood/AsyncImageView
And more, you can refer to the sample code by Apple about LazyTableImages
- https://developer.apple.com/library/ios/samplecode/LazyTableImages/Introduction/Intro.html
UPDATE:
For SDWebImage
follow this guide. It's very good.
http://iosmadesimple.blogspot.in/2013/04/lazy-image-loading.html