views:

578

answers:

1

Greetings! I'm trying to borrow the view flip concept from Apple's TheElements sample app. This sample employs a container UIView in which you can swap between two subviews. The flip is achieved using setAnimationTransition:forView:cache: and removing/adding each subview.

In general, the flip works and I can swap between my two views (a UITableView with headers/footers, and a MKMapView). However, various (consistently chosen) areas of my table view are obliterated (using the table view's background color) before and after the table view is flipped, and I don't understand why.

I can't find anything unusual about the table view in terms of drawing. In the case of the sample app, the view is drawn from scratch, but I would hope that doesn't factor in to it! I'm really hoping it's something simple - maybe a UITableView property setting?

Clues appreciated. Thanks!

Update: When I slow down the animation, I begin to get an understanding of what is being disturbed (though I still don't know why). My table header view contains an image view and label view. Now, imagine the CGRects for those two views (only without any visible content, just a background color) being redrawn further down the table view, right over the table rows.

This also happens with another chunk of real estate that appears to come from a table view cell that was set with a custom height (to size the text within it).

I dropped a gratuitous number of breakpoints throughout my code (where things are sized, created and whatnot), and not one of them is hit during the transition.

I even tried placing my table view inside a UIView and targeting that for the transition instead. No difference.

From the API docs:

Caching can improve performance but if you set this parameter to YES, you must not update the view or its subviews during the transition. Updating the view and its subviews may interfere with the caching behaviors and cause the view contents to be rendered incorrectly (or in the wrong location) during the animation. You must wait until the transition ends to update the view.

That's all well and good, but I'm not updating any views or subviews during the transition. (At least not on purpose! Again, see the note about the breakpoints. Nothing got hit.)

A: 

Amazing.

Answer: In this case, it appears to only happen in ... the Simulator! On the device, it's fine.

I was thinking that such a run-of-the-mill transition would be the sort of thing that would render identically on the Simulator and the device.

I was wrong. So if you ever see animation transition glitches on the simulator, hang in there. It might be fine after all.

Joe D'Andrea
That's weird. In my project the problem still exist in the iPhone 3G. Here is my question and project: http://stackoverflow.com/questions/2108972/flickering-animation-with-uiviewanimationtransitionflip
HansPinckaers