[Drawkit] two views, different layers?
Graham Cox
graham.cox at bigpond.com
Sun Jul 27 17:32:59 PDT 2008
Hi James,
What you're describing is possible but you'll have to do quite a bit
of work, somewhere. The visibility of a layer is a property of the
layer, and the view just renders everything in the drawing by asking
each layer to draw itself - if the layer is hidden, it won't be drawn.
A (somewhat fiddly) way to do it: The view is passed to the layer's -
drawRect:inView: method, so if you subclass the layer and override
that method, you could skip the drawing for specific views, just
calling super's implementation to draw the content. It's not that
clean because it means the layer has to have knowledge of the view, so
a cleaner solution would be to devise some sort of protocol whereby
the layer can ask the view "should I draw"? and the view will say yes
or no.
To make it more awkward still, the scroll position of each view is a
property of the scrollview that contains it, and there's no
synchronisation - you'd have to figure out a way to keep all the views
scrolled to the same position. Not impossible, but definitely awkward.
I can think of other solutions that could also be made to work - like
having a custom view controller that managed two views which were
embedded in the same scrollview - but it's not going to be all that
trivial.
cheers, Graham
On 28 Jul 2008, at 7:03 am, James Maxwell wrote:
> Hey All,
>
> I've got a rather strange requirement for the app I'm working on. I
> want two views, which appear to be different, but which are closely
> related in content. They should remain synchronized, in the sense
> that they should autoscroll together (among other things, to do with
> music, specifically). I was planning on using two drawings, but this
> seems like it might be a real hassle... So, I'm wondering whether
> it's possible to have two views on the same drawing, with view A
> having a certain layer hidden, and view B having only the hidden
> layer from view A visible? Make sense? Strange, I know... but is it
> possible?
>
> cheers,
>
> J.
>
>
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net
More information about the Drawkit
mailing list