Which image caching library for iOS?

前端 未结 7 550
轮回少年
轮回少年 2021-01-30 09:32

I am building a photo album app and find a few image caching libraries, namely:

  • JMImageCache
  • HJCache
  • SDWebImage

What one you\'d re

7条回答
  •  有刺的猬
    2021-01-30 10:27

    Image async downloading and caching is not a simple task. It needs to be done well otherwise it will defeat its purpose. Therefore I strongly suggest that eventually you build your own. Having said that, I needed a quick and simple solution in order to move forward with the development of my application.

    I found these solutions:

    • HJCache
    • SDWebImage
    • Apple's LazyTableImages
    • An adaption from Apple's LazyTableImages,MHLazyTableImages

    I tried HJCache, but it didn't offer great scrolling performance when handling large images (1.5M+). For small images it worked great though. Tried both LazyTableImages as well but the integration wasn't simple.

    Ultimately, I chose SDWebImage. The integration couldn't be simpler. Once you have linked the library to your project all you need to do is:

    [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
                   placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    

    in your tableView:cellForRowAtIndexPath:.

    Additionally:

    • Works with custom cells as well
    • Doesn't block the UI
    • Offers great scrolling performance
    • Image downloading and caching is seamless.

提交回复
热议问题