2010-01-04 14 views
6

Actualmente tengo este código que funciona biencacao setAnimationDidStopSelector

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

- (void)animationDone:(NSString *)animationID finished:(BOOL)finished context:(void *)context { 
// do stuff here 
} 

de registro el valor de animationID me da un valor nulo.

¿Cómo puedo pasar el valor al @selector?

me trataron

[UIView setAnimationDidStopSelector:@selector(animationDone:@"animation1"finished:context:)]; 

Eso me da un error.

Gracias, Tee

Respuesta

16

La cadena que se pasa al selector es el que se utiliza en esta llamada al método:

[UIView beginAnimations:@"your_animation_name_here" context:NULL]; 
[UIView setAnimationDuration:0.5]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)]; 
// whatever changes here 
[UIView commitAnimations]; 

Después, puede hacer esto:

- (void)animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context 
{ 
    if ([animationID isEqualToString:@"your_animation_name_here"]) 
    { 
     // something done after the animation 
    } 
} 
+1

esto: '[UIView setAnimationDidStopSelector: @selector (animationDone: finished: context :)];' debe ser esto: '[UIView setAnimationDidStopSelector: @selector (animationFinished: finished: context t :)]; ' –

+0

¡Gracias por el comentario! Corregido –