我正在目标 C 中创建一个游戏,但我被一个问题阻止了:我有一个警告要在 @selector 上传递多个变量。我想要做的是在我的 UIViewController 中调用一个方法,但要延迟一段时间。所以我尝试制作第一个方法,在延迟后调用另一个方法,如下所示:
-(void)AnimationCoinInitWith_x:(int)x y:(int)y w:(int)w h:(int)h afterDelay:(NSTimeInterval)t
{
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
[self methodSignatureForSelector:@selector(AnimationCoinCopyInitWith_x:y:w:h:)]];
[invocation setTarget:self];
[invocation setSelector:@selector(AnimationCoinCopyInitWith_x:y:w:h:)];
[invocation setArgument:x atIndex:1];
[invocation setArgument:y atIndex:2];
[invocation setArgument:w atIndex:3];
[invocation setArgument:h atIndex:4];
[NSTimer scheduledTimerWithTimeInterval:t invocation:invocation repeats:NO];
}
-(void)AnimationCoinCopyInitWith_x:(int)x y:(int)y w:(int)w h:(int)h
{
UIImageView* imageViewCoin = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
[imageViewCoin setAnimationImages:images];
[imageViewCoin setAnimationRepeatCount:1000];
[imageViewCoin setAnimationDuration:(1/24)];
[imageViewCoin startAnimating];
[self addSubview:imageViewCoin];
[imageViewCoin release];
}
但它不起作用,我不知道为什么。
谢谢你的帮助 !