Je sais que cette question est souvent posée mais j'ai essayé toutes les autres réponses et je n'arrive pas à comprendre pourquoi le sélecteur d'arrêt d'animation n'est pas appelé. Voici le code:setAnimationDidStopSelector: ne pas se faire appeler
-(void) moveImage:(UIImageView *)image duration:(NSTimeInterval)duration curve:(int)curve x:(CGFloat)x y:(CGFloat)y annKey:(NSString *) annKey{
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];
CGAffineTransform transform = CGAffineTransformMakeTranslation(x, y);
image.transform = transform;
[UIView beginAnimations:annKey context:NULL];
[UIView commitAnimations];
}
Ceci est la fonction principale d'animation qui est envoyé tous les paramètres corrects.
- (void)animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context
{
if ([animationID isEqualToString:@"Burn"])
{
NSLog(@"Animation: %@ has finished.",animationID);
}
NSLog(@"This does not get called, why not?");
}
Aucun de mes NSLogs n'affiche le texte. Qu'est-ce que je fais mal?
Pourquoi avez-vous deux 'beginAnimations'? – RyJ
Désolé, c'était une erreur, j'ai enlevé le premier du code. Mais le problème existe toujours. – JH95
Déplacez cette ligne, '[UIView beginAnimations: annKey context: NULL];' en haut de la méthode 'moveImage: duration: courbe: x: y: annKey:'. – titaniumdecoy