views:

352

answers:

2

I have a Custom view. This custom view has two UIImageViews - imageview1 and imageview2.

[UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:2.00]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(transitionDidStop:finished:context:)]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self cache:YES]; if(frontVisible) { [imageview1 removeFromSuperview]; [self addSubview: imageview2]; } else { [imageview2 removeFromSuperview]; [self addSubview: imageview1]; } frontVisible = !frontVisible; [UIView commitAnimations];


The image changes from imageview1 to imageview2 and viceversa but I dont get the flip effect. Instead I see the fading out of one image as the other appears.

A: 

Not really sure but I checked the documentation and found this:

Discussion

If you want to change the appearance of a view during a transition—for example, flip from one view to another—then use a container view, an instance of UIView, as follows:

  1. Begin an animation block.
  2. Set the transition on the container view.
  3. Remove the subview from the container view.
  4. Add the new subview to the container view.
  5. Commit the animation block.

So it says you have to create a container view in order to make it work properly.

JoostK
I do get the flip now when I use UIViewAnimationTransitionFlipFromLeft. (I don't how I got this working.)But if I change the transition to UIViewAnimationTransitionCurlUp I still see that one of the images fades out as the other appears.I am not able to understand what is so special with CurlUp
Minar
+1  A: 

The reason you're not getting the curl transition to work is because the curl transition does not work in the simulator. It shows up as a fade instead.

Dave DeLong