I am using some code that was originally taken from the Apple ViewTransitions sample to exchange two views with each other.
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:kCATransitionFade];
[animation setDuration:0.3f];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
[[container layer] addAnimation:animation forKey:@"swap"];
When my transition is done on devlice, sometimes I get one flash frame of the last frame of the transition animation, and then the animation plays smoothly. This gives a very dramatic 2nd view effect that flickers and then exits again before the smooth animation is performed.
The main difference between my example and the Apple example is that my views are not full-screen, I have a UIView container that contains both subviews, and I apply my animation to the container layer, and not to the root view. I do not see that this should be of great importance, though.
This problem does not occur at all in the simulator and is intermittent (about 60-70% of the time) on the device. Does anyone else see this behavior, and if so, how did you get around it?
Updated with additional information:
The code was originally part of an animation of several parts, but I moved it to trigger it with a button to isolate the problem. The problem occurs in both situations.
Animation delegates were implemented but were removed to try to isolate the problem.
The views do not change during the animation, and are actually called [container setUserInteractionEnabled:NO](but the problem also occurs without disabling user interaction).
I tried to start the animation from the middle of the transition and finish it to the end with setStartProgressand setEndProgress, again, the problem persists.
.