Best practices to load very large images in a scroll view for zooming?

190 views Asked by At

I'm loading a very large image (8000x8000) into an UIImageView that's in a UIScrollView. This works but it consumes a lot of memory and takes a couple of seconds to load.

I've looked into a better approach and all the examples I have found are based on a 2010 WWDC example called PhotoScroller. This example uses a custom UIView with CATiledLayer to break the large image into smaller tiles and draw them to the screen.

https://github.com/master-nevi/WWDC-2010/tree/master/PhotoScroller

Is there a more modern way to do this in iOS 13 or is this still the best approach?

1

There are 1 answers

5
matt On

It is still the best approach. 8000x8000 is huge. You cannot load the whole image at once. CATiledLayer means you only need a few tiles loaded at a time — just the portion of the image that the user is looking at at the moment.