2012-01-05 6 views
6

私のiPhoneアプリケーションでアニメーションの完成後いくつかのメソッドを呼び出す

私は特定のアニメーションを行っています。

...私はいくつかの方法tocallたい、このアニメーションが完了した後

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

ように私は私はそれをどのように行うのですかブロックアニメーションABT何かまたは

DidStopAnimation通知

を知っています... .. ありがとう..

答えて

11

は、ブロックを使用することは、この目的のために推奨されます:

animateWithDuration:animations:completion: 

:この

[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]; 

そして、あなたはメソッドを実装することができます

のiOS 4以降で
-(void)afterAnimationStops{ 

} 
関連する問題