Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Infinite loop when adding CATiledLayer to UIView

I have a UIView in which I add a CATiledLayer and implement 'drawLayer'. If I use a UIViewController and add the layer to a new subview of the controller, then everything is ok.

If I however try to use a UIView to and do all the craetion and drawing within this, then I get a infinite loop at the point shown below when I add this view to a superview.

0x002cfafb  <+0425>  ja     0x2cfa23 <-[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]+209>

What am I missing?

Update: By removing 'layer.delegate = self', the code no longer crashes...

like image 576
Egil Jansson Avatar asked Nov 24 '25 12:11

Egil Jansson


1 Answers

Just found this:

http://www.iphonedevsdk.com/forum/iphone-sdk-development/18121-calayer-interesting-crash.html

"You can't set the delegate to be the same as the view's layer's delegate, which by default is the view itself"

like image 91
Egil Jansson Avatar answered Nov 28 '25 16:11

Egil Jansson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!