tags:

views:

184

answers:

1

hi,

I'm a noob in objective-c and cocoa, and I would like to implement a simple animation of UIImageView with flipping animation. But I'm having a hard time doing it. Below are my snippets:

UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0,0,33,33)];
UIImageView *img1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:IMG1]];
UIImageView *img2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:IMG2]];         
[containerView addSubview:img1];
[containerView addSubview:img2];
[self.view addSubview:containerView];

CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:containerView cache:YES];
[containerView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView commitAnimations];

Thanks.

A: 

You refer to an object called view which is never declared. I think you need to change your second-to-last line to

[containerView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

See if that helps.

Jonathan Sterling
oopss, sorry its a mistypo. thanks
sasayins
note my comment above doesn't mean that my problem was resolved.
sasayins