Re: Layers in NSCollectionView
Re: Layers in NSCollectionView
- Subject: Re: Layers in NSCollectionView
- From: Kyle Sluder <email@hidden>
- Date: Sun, 02 Dec 2012 18:32:11 -0800
On Dec 2, 2012, at 6:23 PM, Gordon Apple <email@hidden> wrote:
> I tried setting only that in IB. I also tried setting everything in that view nib. OriginalLayer is non-nil in the trace, but, as you see, gets replaced with the one with color background.
Well, it's probably not a good idea to turn on layer-backing for a view in nib and then try to transform it into a layer-hosting view by assigning to its layer property and then calling -setWantsLayer:YES. There's a chance that NSView will say, "oh, my wantsLayer property is already yes; I'll just keep on doing my thing" even though your intent was to remove AppKit's ownership of your layer.
To be honest, the difference between layer-backed and layer-hosting views is still murky, though the situation has gotten slightly better with the 10.8 AppKit release notes. I just want one document that explicitly describes *precisely* what AppKit does and does not control in each case. :-/
I did just remember something, though: NSCollectionView copies its collection items around in some sort of crazy way that was subtly changed with the introduction of NSViewController. Is it possible that the views in your collection view are *NOT* the same instances that were unarchived from nib, but rather *copies* of those views created by sending -encodeWithCoder: to the collection item's view?
--Kyle Sluder
>
>
> On 12/2/12 5:48 PM, "Kyle Sluder" <email@hidden> wrote:
>
> On Sun, Dec 2, 2012, at 03:07 PM, Gordon Apple wrote:
> > I have a simple subview in my NSCollectionView prototype. (Collection
> > view
> > is in a popover. Popover launched from a floating control panel.) It
> > contains the following:
> >
> > - (void) awakeFromNib {
> > CALayer *originalLayer = self.layer;
> > CALayer *newLayer = [CALayer layer];
> > newLayer.backgroundColor = [[NSColor magentaColor] CGColor];
> > self.layer = newLayer;
> > self.wantsLayer = YES;
> > // [self getThePlayer];
> > // [self addPlayerLayer];
> > }
> >
> > Code gets executed, but no visible color. originalLayer is nil.
> > Commented
> > code is for testing. If I can’t simply get a color layer to work,
> > there’s
> > no chance of that working. I’ve tried adding a sublayer with color
> > background — no go. Controls in collection view work just fine.
> >
> > I’m reasonably well versed in CALayers and have used them extensively.
> > Is
> > there any reason why this doesn’t work?
>
> Did you enable layer-backing on the enclosing scroll view?
>
> --Kyle Sluder
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden