Search code examples
objective-ccore-animation

Can`t draw in CAlayer


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.


Solution

  • 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.