问题
Does anyone know of a good tutorial that shows how to lazy load images in a UITableView? I've searched online but the only one I found that looked like it did what I wanted was hard to follow because only parts of the code were shown and I'm new at this so I didn't understand how to hook everything up.
回答1:
I suggest you check out the SDWebImage project on github, I use it for my table views when I need to load a remote image into the cells.
https://github.com/rs/SDWebImage
回答2:
As Daniel suggested SDWebImage https://github.com/rs/SDWebImage, I don't know of any tutorial, but in amongst the KTPhotoBrowser samples there is one that uses SDWebImage that can show you how to do it https://github.com/kirbyt/KTPhotoBrowser/tree/master/src/Sample/Classes/SDWebImageSample
If I remember correctly you need to import and use the SDWebImage UIImageView category and then pass the url to the cell and call
setImageWithURL:[NSURL URLWithString:@"yoururl"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]
when setting the cell image.
回答3:
I haven't actually followed it, but this one has plenty of positive commentary: http://www.markj.net/iphone-asynchronous-table-image/
来源:https://stackoverflow.com/questions/7060113/lazyload-images-on-the-iphone