Cocoa setAnimationDidStopSelector
Currently I have this code that works fine
[UIView setAnimationDidStopSelector:@selector(animationDone:finished:context:)];
- (void)animationDone:(NSString *)animationID finished:(BOOL)finished context:(void *)context {
// do stuff here
}
Logging the value of animationID gives me a null.
How can I pass value to the @selector?
I tried
[UIView setAnimationDidStopSelec开发者_运维百科tor:@selector(animationDone:@"animation1"finished:context:)];
That gives me an error.
Thanks, Tee
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];
Afterwards, 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
}
}
精彩评论