Re: resizing window containing NSView with CALayer
Re: resizing window containing NSView with CALayer
- Subject: Re: resizing window containing NSView with CALayer
- From: Graham Cox <email@hidden>
- Date: Mon, 08 Aug 2011 10:46:39 +1000
On 08/08/2011, at 5:52 AM, julius wrote:
> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
I didn't notice first time through that this is where your code resides (sometimes the most obvious errors pass by when you're looking out for a more subtle error). It's certainly wrong to put it there. A view will typically initialise its layer as part of its own initialisation, i.e. the layer set up should be done in the view's -initWithFrame: method.
At the time -applicationDidFinishLaunching, the view might exist depending on your app architecture, but then again it might not. So moving the code to its natural home should be done whether it has a bearing on this problem or not. (The issue here isn't just about whether the view exists, it's also about good design - the app delegate object has no business fretting about view objects that are none of its business).
> I get exactly the same behaviour if I leave out all the layer stuff and instead code the following in the view
>
> - (void)drawRect:(NSRect)dirtyRect {
> [[NSColor blackColor]set];
> [NSBezierPath fillRect:[self bounds]];
> } // end drawRect
Well, in that case the struts (which end up setting the autoresizing mask for the view) must either be set incorrectly, or else the view in IB that you think you're setting is not the view object you actually end up with in your window. A common mistake is to add the view in IB and also create and add it in code. Do one or the other, never both.
--Graham
_______________________________________________
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