Search code examples
iosuitableviewcachinguiimagensfilemanager

Reading UIImage data while scrolling, pros and cons



I'm doing some sort of scroller for some images i've saved on the device using NSFileManager,

Everytime the user scrolls into the specific cell i read the image data and load it, and the scrolling is a bit slow and choppy,

Currently to read an image from the disk i use [NSFileManager contentsAtPath: myFile] and then [UIImage imageWithData: imageData] .

I wanted to know if theres an easier and more efficient way to do this , I thought of just preloading the images into memory, but these images are 700x700 pixels each and i'm afraid it would cause over-memory usage,

Anyways, i also saw on some other thread that JPG Representations seem to take up a lot more memory than PNG, so after changing everything to PNG , it seemed to be working a bit better, but still not fast enough.

Would love to hear from your experiences :)
Shai.


Solution

  • Apple has a lazy image loading example that can get you started loading images from local or network locations.