On 17 Feb 2010, at 09:23, Keith Duncan wrote:

> 
> On 16 Feb 2010, at 21:40, David Duncan wrote:
> 
>>> Calling it in -initWithFrame: is too early and the view fails to 'draw'.
>> 
>> If you are creating the view programmatically, -initWithFrame: should be 
>> fine. If your loading from a nib, then -awakeFromNib is the appropriate 
>> place.
> 
> That's actually a more distilled version of my question. When your layer 
> hosting view may be instantiated programatically, or from a NIB; there is no 
> good place that covers both since the -init methods are too early (I haven't 
> needed to test -initWithCoder: yet).
> 
> Nor have I determined the boundary condition for which it works afterwards, I 
> suspect it's after the has been placed in the view hierarchy. But if that's 
> the case, does the view hierarchy need to be rooted in a window or can it be 
> floating.
> 
> One simple workaround I've been using (but wanted to check for a better 
> solution) is to call -setWantsLayer:YES in -initWithFrame: and layer-back the 
> view's parent in the XIB.

Hi Keith,

Whilst I was putting together something recently (it's on my blog is you want 
to see the code) but ended up with the ability to add the layers in 
-awakeFromNib because the view will always be defined in advance.

However I essentially ended up having to call -setWantsLayer: on my view and on 
the parent view as two calls because the parent view didn't always seem to pass 
the layer-backing on down to my view.

I thought that adding layer-backing in -initWithFrame: worked (you might need 
to add a layer at the same time) and I think you'll get away with calling it in 
both -initWithFrame: and in -awakeFromNib without any problems. At the very 
least you could check in -awakeFromNib to see if the view is already 
layer-backed and only call setWantsLayer: if it is not.

Simon Wolf

Website: http://www.ottersoftware.com
Twitter: http://www.twitter.com/sgaw
iChat: simon.w...@mac.com_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to