On May 17, 2011, at 9:49 AM, Bill Cheeseman wrote:

> On May 17, 2011, at 11:33 AM, David Duncan wrote:
> 
>> There should be no actual restriction like that however. That said, as you 
>> point out, if you have view that supports layers and come from a nib, you 
>> often have to duplicate work to allow it to work in both situations.
> 
> I'm not sure I follow you.
> 
> I am aware that there are a number of commentaries explaining that loading a 
> nib file that contains accessibility settings interferes with a layer tree 
> that was constructed in code before the nib was loaded -- hence the 
> recommendation to construct the layer tree in -awakeFromNib, not in 
> -initWithFrame:. However, my view's nib file does not use any of the 
> Interface Builder accessibility features, so I'm not at all clear why I 
> should have run afoul of this issue. Apple's documentation on the point is 
> quite cryptic.


The basic problem comes about when a view in the nib has wantsLayer=NO, but the 
view itself always wants to be layer backed. If you setWantsLayer:YES inside of 
-initWithFrame:, then by the time you get to -awakeFromNib wantsLayer=NO again. 
As such, if you did anything that relied on the view being layer backed (such 
as setting its layer and manipulating the layer tree) then that work needs to 
be done again.

However, this should not apply to any layers you create that aren't implanted 
into the view. You should be able to create layers to your hearts content 
inside of -initWithFrame: as long as you don't try to manipulate the view's 
layer tree. As such your statement that you couldn't create layers there seems 
to be indicative of some other issue.

My addendum is if you are creating a view that should both support loading from 
a nib, and creation purely in code. In that situation, you basically need to 
duplicate the layer setup code, since -awakeFromNib won't be called in the 
programmatic case, while in the nib case you may need to re-do some work that 
is done in -initWithFrame:.

If only nib loading called -initWithCoder: on Mac OS X :).
--
David Duncan

_______________________________________________

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