0
votes

I have a UIScrollView with paging enabled. All the images were loaded at the start and added to the UIImageViews, but I had a memory-issue as it were more images, so I decided to load the after next image while scrolling if the image isn't set yet. If i get a memory warning, I remove all images except of the current.

The problem is, that the scrollview hangs for a few milliseconds if I scroll.

I'm using

UIImage *image = [UIImage imageNamed:@"path/to/image.png"];

to load the images. If I use the method imageWithContentsOfFile, it cost alot more time.

Is there a way to show a pixelated image like in the default Photoapp until it's fully loaded?

Thanks for your answers in advance.

1

1 Answers

0
votes
[UIImage imageNamed:]

caches images for you, so that's why it's better than imageWithContentsOfFile. Since these images are displayed in a table cell, presumably they don't need to be that large. What are the images dimensions on the file system? If you just put the UIImage in a UIImageView and depend on that for scaling, my guess is the scaling happens while you scroll. Can you create thumbnails for each image on the file system and use those?