0

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?

Berry Blue
  • 15,330
  • 18
  • 62
  • 113

1 Answers1

0

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.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • You might want to look at this section of my book: http://www.apeth.com/iOSBook/ch20.html#_tiling Nothing significant has changed since I wrote that. – matt Nov 07 '19 at 21:14
  • Ok, thank you. One thing I don't get about this approach is having to create tiles at different scales. This ends up using a lot of disk space. – Berry Blue Nov 07 '19 at 21:33
  • You only need the different scales if you also want zooming. – matt Nov 07 '19 at 21:36
  • And besides that's the whole point of the example. Disk space you've got plenty of! What you don't have is RAM memory. – matt Nov 07 '19 at 21:43
  • Here's the zooming section of my book: http://www.apeth.com/iOSBook/ch20.html#_zooming_with_detail You can see the point is, if you don't use the extra tiles, you can lose detail as the user zooms in. – matt Nov 07 '19 at 21:44