目前我有这个代码可以正常工作
[UIView setAnimationDidStopSelector:@selector(animationDone:finished:context:)];
- (void)animationDone:(NSString *)animationID finished:(BOOL)finished context:(void *)context {
// do stuff here
}
记录animationID的值使我为空。
如何将值传递给@selector?
我试过
[UIView setAnimationDidStopSelector:@selector(animationDone:@"animation1"finished:context:)];
那给我一个错误。
谢谢,
球座
最佳答案
传递给选择器的字符串是您在此方法调用中使用的字符串:
[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];
之后,您可以执行以下操作:
- (void)animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context
{
if ([animationID isEqualToString:@"your_animation_name_here"])
{
// something done after the animation
}
}
关于iphone - cocoa setAnimationDidStopSelector,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1999515/