4

I'm looking for any advice on ways to have a rather large scrollview (let's say 8192x8192) which is essentially a grid and it has subviews of about 5-100 buttons placed in it.

The brute force approach runs out of memory as CALayer seems to be allocating a bitmap for the size of the scrollview's content (the memory issue is especially prominent when zooming is used)

I next added CATiledLayer to it, that's fixed the memory issue but there is a blurry effect on the grid as tiles are generated asynchronously and is still not ideal in that it's using a lot of memory for what is essentially a trivial 'draw some lines' task.

It seems like if I could somehow get control to draw my own grid via OpenGL each frame and tell UIKit not to create a bitmap buffer for the scrollview it would be perfect but not sure if this is feasible or even the right approach?

On Android I just took control of the entire drawing/zooming/panning but this seems vastly overkill on iOS which seems to offer most of this already?

sradforth
  • 2,176
  • 2
  • 23
  • 37
  • There's a hint that adding subviews might be the way to do it (i.e. rects for each line of the grid) however I can't get that to work with the zoom yet... – sradforth Aug 26 '12 at 20:00
  • There is a WWDC video from a few years back (2009?) I think it was called "Mastering Scroll Views" it described in detail how to do a tiled scroll view, which sounds like what you want if the asynchronicity of CATiledLayer is unacceptable. Maybe check it out and see if tha tmeets your needs. – Carl Veazey Sep 04 '12 at 23:58
  • Hi Carl, happy to mark this as the answer if you reply there. I've opted for the CATiledLayer approach for the moment but will be revisiting it. – sradforth Sep 19 '12 at 08:13

1 Answers1

1

You should check out the WWDC 2009 video session 102: "Mastering iPhone Scroll Views" along with the ScrollViewSuite sample project from Apple. They explain how to do a tiled scroll view with different zoom levels, which sounds like it is what you need.

Carl Veazey
  • 18,392
  • 8
  • 66
  • 81
  • Any idea where one (with a developer account) can find these videos? The option to purchase seems to have disappeared. – Tim Arnold Jan 27 '13 at 16:46
  • I think you can get it [here](https://github.com/darcyliu/SampleCode/tree/master/ScrollViewSuite) – CaseyB Jan 03 '14 at 01:22