views:

201

answers:

2

HI All.

I have subclass of UIScrollView. IN this class I have added some imageView.layer to self.layer. And when I call [imageView.layer setNeedsDisplay] my implemented delegate never called.

-(void)drawLayer:(CALayer*)layer :(CGContextRef)context 

I`ve also set

imageView.layer.delegate = self

Could anyone tell me where I must set delegate function to make this to work.

Thank you for advance.

A: 

There are some things a little bit odd with you approach.

If ou have a ScrollView and an ImageView you don't need to add the layers, you can just do
[scrollView addSubview: imageView];

Also, you don't need a delegate for drawing a UIView into a UIWindow. If, however, you want to add a delegate still you can do this: imageView.delegate = A ImageView should not be his own delegate, you will need some ViewController, better a ScrollViewController.

reforged
I want to say that my problem is solved particularly. I define another class and added to this class only one function drawLayer :inContect function and set object of this class to my layer delegate. At the beggining this function is called but when i call[myLayer setNeedsDisplay] function this function is never called.
Ann
A: 
  1. The method name is -drawLayer:inContext:. The delegate's method signature should be like this:

    //                                  vvvvvvvvv
    - (void)drawLayer:(CALayer *)layer  inContext:(CGContextRef)ctx
    
  2. Don't override the delegate of another layer attached to a view (which is that view). This will make the view cannot operate normally.

KennyTM