开发者

Do something when animation is ready.

开发者 https://www.devze.com 2022-12-26 03:15 出处:网络
I have a animation in my navigationbased application. [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.5];

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 don't want to pop my ViewController before my animation is ready.


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.


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
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号