Cocoa setAnimationDidStopSelector

I currently have this code that works great

[UIView setAnimationDidStopSelector:@selector(animationDone:finished:context:)]; - (void)animationDone:(NSString *)animationID finished:(BOOL)finished context:(void *)context { // do stuff here } 

Writing the animationID value gives me zero.

How to pass value to @selector element?

I tried

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

This gives me an error.

Thank you Tee

+6
objective-c iphone
source share
1 answer

The string passed to the selector is the one you use in this method call:

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

Subsequently, you can do this:

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

All Articles