Present and zoom large images on iOS without CATiledLayer

2.8k views Asked by At

I'd like to present and allow the user to zoom large images on the iPhone and iPad in much the same way that the Photos app works.

I realize CATiledLayer is the goto class for this, but the aesthetic it uses won't work for my application. It renders tiles one after another, while the Photos app renders the whole screen at once (and shows a pixellated version during and after a zoom until the app can catch up).

I could certainly implement a view which renders the image in the background after each zoom. However, once the source image gets to large, this will crash the app. So tiling is appealing, I would just prefer to not update the screen until all tiles are ready (and show a lower-res image in the meantime).

Has anyone tried to implement something like this? Any ideas?

2

There are 2 answers

0
Luis On BEST ANSWER

I guess you can have two views: one ImageView with a low res image, and on top a custom view with a CaTiledLayer, with transparent background and hidden at the beginning.

So, when zooming (you'll need to apply zoom to both views) and you need extra resolution, just show the catiledlayered view, so it will load tiles while showing the lowres (and pixelated) on not loaded tiles.

0
dwb On

Apple's PhotoScroller and ScrollViewSuite samples show how to do this and more.

There's also a 2010 WWDC video titled "Designing Apps with Scroll Views" that explains PhotoScroller.