2010-02-18 8 views
2

dire que j'ai ...Comment savoir quand une animation de base a fini?

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:0.5]; 

CGPoint position = myObject.center; 
position.x = position.x - 10; 

myObject.center = position; 

[UIView commitAnimations]; 

animation de base se produit sur un thread séparé est-il un moyen de savoir quand une animation est terminée? c'est-à-dire, il y a peut-être un moyen de connecter un appel de fonction pour savoir quand il a fini ...?

(p.s Je sais que je peux utiliser une minuterie qui déclenche une méthode après 0.5s par exemple dans ce exemple ci-dessus, mais cela semble assez ringard)

une aide très appréciée!

Répondre

5

Vous pouvez définir le setAnimationDidStopSelector:

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/clm/UIView/setAnimationDidStopSelector:

  • (void) setAnimationDidStopSelector: sélecteur

(SEL) mettent ensuite en œuvre une méthode de ce sélecteur

[UIView setAnimationDidStopSelector:@selector(finishedAnimation:finished:context:)]; 


- (void) finishedAnimation:(NSString *)id finished:(BOOL) finished context:(void *) context { 
    ...... 
} 

Espérons que cette aide s.

Questions connexes