I've been working on something for weeks now (iOS) and I can't seem to figure out an acceptable solution.
Requirements
- Display a 10000x10000 pixel background image
- Zooming and scrolling responsive
- Overlay on top that has custom drawing
- Elements in overlay are interactive (tapping and highlighting elements, etc) and pieces can be turned on or off.
- iOS 4.0
Think of it as a geographic map of a fictional town, with a crazy system of roads, lines, areas and buildings drawn on top. A mixture of CGPaths with fills of various opacities, some icon images etc. It's like a more complicated version of google maps app.
What i've tried:
1 - Multiple CATiled Layers
View Hierarchy:
- ScrollView
- ->ContainerView
- -->TiledView (CATiledLayer 10000x10000)
- --->OverlayView (CATiledLayer 10000x10000)
Results: Drops tiles from magic apple cache left and right. Two CATiledlayers doesn't seem to be the right path. Updates to overlay aren't fast.
2 - Subclass TiledView for OverlayView
View Hierarchy:
- ScrollView
- ->OverlayView (Subclass of TiledView CATiledLayer 10000x10000)
Results: Takes way too long to render updates for the overlay. Slow to update tiles
3 - Scrollview w/ a single container view
View Hierarchy:
- ScrollView
- ->ContainerView (10000x10000)
- -->OverlayView (CALayer 10000x10000)
- -->TiledView (CATiledLayer 10000x10000)
Results: Fails to work because OverlayView consumes too much memory. TileView is fine because it is backed by CATiledLayer
4 - OverlayView that uses scroll delegate and CTM scale/translate to simulate being large
View Hierarchy:
- OverlayView (CALayer 1024x768)
- ScrollView
- ->TiledView (CATiledLayer 10000x10000)
Results: I use the scrollview delegates to adjust the offset and zoom of the overlay view. The problem with this method is that drawrect is called like 100 times a second and the overlay view can't draw fast enough so it's completely lagged down to 1fps.
So that's where I am at. I feel this last method is on to something, but would require some crazy work to tame the drawrect madness. Other thoughts would be to try to tackle something in OpenGL.
Before I go about doing those I'd thought I'd ask the community to see what they would do/have done facing similar requirements.
Thanks for any help.