2012-01-05 37 views
6

在我的iPhone应用程序中动画完成后想要调用一些方法

我在做某些动画。 像

[UIView beginAnimations:@"stalk" context:nil]; 
    [UIView setAnimationDuration:1]; 
    [UIView setAnimationBeginsFromCurrentState:YES]; 
    self.frame=originalSelf; 
    [UIView commitAnimations]; 

这个动画我想tocall一些方法完成后...

我知道的东西ABT块动画或

DidStopAnimation通知

我怎么做.. .. 谢谢..

回答

11

在iOS 4及更高版本,建议为此目的使用块:

[UIView animateWithDuration:1 
        animations:^{ 
         self.frame=originalSelf;} 
        completion:^(BOOL finished){ 

         //My method call; 
        } 
    ]; 
5

尝试使用

[UIView beginAnimations:@"stalk" context:nil]; 
[UIView setAnimationDuration:1]; 
[UIView setAnimationBeginsFromCurrentState:YES]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(afterAnimationStops)] 
self.frame=originalSelf; 
[UIView commitAnimations]; 

然后你就可以实现方法

-(void)afterAnimationStops{ 

}