• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem with CALayer delegate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with CALayer delegate


  • Subject: Problem with CALayer delegate
  • From: Francois-Jean De Brienne <email@hidden>
  • Date: Fri, 22 Feb 2008 23:52:59 -0500

Hello everyone,

I'm a very new cocoa developer (I switched two months ago) but an experienced (15+ years) developer.

I'm struggling trying to get a CALayer delegate method, specifically drawLayer being called. I am trying to host the CALayer inside an NSView that would be the delegate for the CALayer.

The CALayer is an attribute of my custom NSView called mainLayer.

Here is the initWithFrame method for my custom NSView:

-(id) initWithFrame: (NSRect) frameRect
{
	self = [super initWithFrame:frameRect];

	if (self)
	{
		mainLayer = [[[CALayer alloc] init] retain];

		[mainLayer setDelegate:self];
		[self setLayer:mainLayer];
		[self setWantsLayer:YES];
	}

	return self;
}

Then, the custom NSView declares a drawLayer method as such (that I'd want to be called from my mainLayer):

-(void)drawLayer:(CALayer*) layer inContext:(CGContextRef)ctx
{
	NSLog (@"Entered drawLayer");
}

Now, whenever I send the setNeedsDisplay message to mainLayer, I assume that drawLayer would be called. It is not.

drawLayer is also declared in the .h for the custom NSView (if that makes any difference).

If I override and define drawRect for my NSView, I can verify that it does enter that method:

- (void)drawRect:(NSRect)rect
{
	NSLog (@"Entered drawRect");
}


What am I doing wrong? _______________________________________________

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


  • Follow-Ups:
    • Re: Problem with CALayer delegate
      • From: "Kyle Sluder" <email@hidden>
    • Re: Problem with CALayer delegate
      • From: Matt Long <email@hidden>
  • Prev by Date: Re: Catch CoreAnimation layer size vs. GPU errors?
  • Next by Date: Re: Unobserved Changes
  • Previous by thread: Re: NSOutlineView autosaving of expanded/collapsed state
  • Next by thread: Re: Problem with CALayer delegate
  • Index(es):
    • Date
    • Thread