1

I'm having a view controller which holds a scroll view, a content view and a CATiledLayer as sublayer in the content view.

If I remove my controllers view from its superview while the CATiledLayer is still busy (rendering a PDF page for instance), I get the weirdest crashes and null references. It seems like CATiledLayer is not happy if you disturbe it. Is there a way I can abort what it is currently doing?

Krumelur
  • 32,180
  • 27
  • 124
  • 263

1 Answers1

1

Am I right that the controller you are removing is the delegate of the CATiledLayer?

Then you have to set the CATiledLayer's delegate to nil when you remove your controller.

May be related link (my own question XD): CATiledLayer drawLayer:inContext: crashing when the view is deallocated while the image to draw is being retrieved

Community
  • 1
  • 1
Altealice
  • 3,572
  • 3
  • 21
  • 41
  • Difficult to say. I'm on MonoTouch :-) The delegate is an inner class of my controller. I have already searched SO and found your other post but it does not work for me. I tried to set my delegate to null, but maybe things jus don't work that way in MT. – Krumelur Mar 10 '11 at 14:50
  • I see. I have no idea about MonoTouch, unfortunately. What I do know is that CATiledLayer processes what it wants to draw in the background then calls the delegate when it is ready to display. If that delegate pointer isn't nil, and the pointer is not pointing to a suitable class, then you will get random crashes, and null refs. – Altealice Mar 10 '11 at 14:54
  • You were right in the end! But I was facing a 2nd problem at the same time: to change pages I use a swipe gesture recognizer. There seems to be a bug in CocoaTouch which causes the recognizer's handler to be triggered a 2nd time if the view it belongs to gets removed from its superview. This caused a NULLREF and I thought it was due to the CATiledLayer. – Krumelur Mar 10 '11 at 16:33
  • Oh. Glad to know I helped a bit. :) – Altealice Mar 11 '11 at 11:08