You need a drawing loop to pass in order to redraw the view before performing the animation. This code is an example of "draw this, and when the next event loop comes around, do this other thing." It's not uncommon to do this in UI code. Your first work-around is attempting the same thing, but in a much more complicated way.
- (void)_runTheAnimation {
// Moved here from -runTheAnimation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:transition forView:self cache:NO];
self.frame = rect2;
[image1 removeFromSuperview];
[self addSubview:image2];
[UIView commitAnimations];
}
- (void)runTheAnimation { //FLIP button calls this
[self displayWithImage1];
[self performSelector:@selector(_runTheAnimation) withObject:nil afterDelay:0.0];
}
Rob Napier
2009-10-01 02:44:02