目前我有这段代码可以正常工作
[UIView setAnimationDidStopSelector:@selector(animationDone:finished:context:)];
- (void)animationDone:(NSString *)animationID finished:(BOOL)finished context:(void *)context {
// do stuff here
}
记录 animationID 的值给我一个 null。
如何将值传递给@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/