views:

1246

answers:

1

My object a sub class of NSObject has CALayer instance variable. I use it for drawing and caching content with its delegate set to my object.

But for some reason drawLayer:inContext: method NEVER gets called. Whereas actionForLayer:forKey: delegate method does get called implying the delegate is getting set properly with the [layer.delegate = self] in the object's init method.

Any suggestions on what is preventing my layer drawing method drawLayer:inContext: from getting called ?

I am called the [layer setNeedDisplay] often. So I guess it is some fundamental error.

+3  A: 

drawLayer:inContext: won't get called if your frame is CGRectZero or offscreen. Also, if your CALayer isn't attached to an existing onscreen layer, it will never draw, no matter how many times you call setNeedDisplay

Kailoa Kadano