views:

80

answers:

2

Hi!

I have a animation in my navigationbased application.

[UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:1.5];
        [UIView setAnimationBeginsFromCurrentState:YES];
        [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown 
                                       forView:self.view cache:YES];        
        [UIImageView commitAnimations];

Directly after this bit of code i call

[self.navigationController popViewControllerAnimated:NO];

The thing is, I dont want to pop my ViewController before my animation is ready. Can someone point me to right directions here ?

+2  A: 

Set animations delegate and didStop selector and pop your view controller in that didStop method you specify:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];

[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown 
                                       forView:self.view cache:YES];        
[UIImageView commitAnimations];

Note, that didStop selector must be of the form specified in docs (see + setAnimationDidStopSelector method in docs for more details):

selector should be of the form: - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context.

Vladimir
+1  A: 

You can set a selector to be called when the animation is finished:

[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];

And in that selector call the pop the view controller.

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {

       // Pop the controller now
    }
Tom Irving