3
UIImageView * frontImageView = [[UIImageView alloc] initWithImage:[UIImage 
                                                                   imageNamed:@"view.png"]];

UIView * containerView = [[UIView alloc] initWithFrame:frontImageView.bounds];
containerView.center = self.view.center;

[self.view addSubview:containerView];
[containerView addSubview:frontImageView];

UIImageView * backImageView = [[UIImageView alloc] initWithImage:[UIImage 
                                                                  imageNamed:@"view.png"]];
backImageView.center = frontImageView.center;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
                       forView:containerView 
                         cache:YES];
[frontImageView removeFromSuperview];
[containerView addSubview:backImageView];
[UIView commitAnimations];

i wanna Flip the containerView,but it doesn't work.

Wang Yanchao
  • 633
  • 1
  • 6
  • 12

3 Answers3

2

This is a similar post about the same problem. @Jason Harwig suggests that you try:

Try using self.view.superview in the animation transition view of the showMoreInfo:

EDIT: Looking at another post, it seems as though adding the subview BEFORE commiting the animations is the problem. Why don't you try that?

Hope that Helps!

Community
  • 1
  • 1
msgambel
  • 7,320
  • 4
  • 46
  • 62
0

dont use

[frontImageView removeFromSuperview];

in this function. What happens is before the animations happen, your view gets removed from superview. Hence, no animation. Instead use this.

[UIView setAnimationDidStopSelector:@selector(removeImageView)];

and make another method,

-(void) removeImageView
{
        if([yourImageView superview])
            [yourImageView removeFromSuperview];
}
mayuur
  • 4,736
  • 4
  • 30
  • 65
0

Set containerView's frame properly.You have set it to frontImageView.bounds that is not right.

Hitesh
  • 1,230
  • 1
  • 10
  • 12