title: Animated UIView frame change causes short flash of previous content before re rendering
body: <p>I've got several <code>UIViews</code> that have a layer class of <code>CATiledLayer</code> because they need to be zoomed using <code>UIScrollViews</code>. I use Quartz to render some PDF pages inside said <code>UIViews</code>. Everything is fine until I try to animate said views frames on page rotation.</p>
  
  <p>The animation is fine, the contents of the view gets scaled quickly and cheaply to match the new frame size. After the animation I call <code>setNeedsDisplay</code> to re-render the whole thing. Now before my <code>-(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)ctx</code> get's called (but after <code>setNeedsDisplay</code>) the views contents shortly reverts back to the previous state (with the remaining pixels being stretched edge pixels in cases where the contents becomes smaller than the view). This results in a flash of some very annoying graphical distortion before reverting back to normal thanks to the new "render pass".</p>
  
  <p>After a lot of debugging I've managed to sort out that this definitely happens during the actual drawing cycle (rather than the application run cycle where I do <code>setNeedsDisplay</code>) but before <code>-(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)ctx</code> even gets called.</p>
  
  <p>What's the sanest way of avoiding or further debugging this?</p>
  
  <p><strong>Edit</strong>: I've thrown together a very simple project that demonstrates this effect perfectly. <a href="http://dl.dropbox.com/u/1478968/EEBug.zip" rel="nofollow noreferrer">http://dl.dropbox.com/u/1478968/EEBug.zip</a>
  PS: There's a sleep(2) in the rendering code just so that the effect could be better observed on screen.</p>