Objective c 是否更新NSmutableArray中UIImageView的映像?

Objective c 是否更新NSmutableArray中UIImageView的映像?,objective-c,uiimageview,Objective C,Uiimageview,我有: 类块继承UIImageView - (void)setJumpAt:(int)frame { NSMutableArray *ret = [SkinConstants BallSelected]; NSString *name = [NSString stringWithFormat:@"balls-%d-%d", color - 1, [[ret objectAtIndex:frame] intValue]]; UIImage *a = [UIImage imageNamed:name

我有:

类块继承UIImageView

- (void)setJumpAt:(int)frame {
NSMutableArray *ret = [SkinConstants BallSelected];
NSString *name = [NSString stringWithFormat:@"balls-%d-%d", color - 1, [[ret objectAtIndex:frame] intValue]];
UIImage *a = [UIImage imageNamed:name];
NSLog(@"%d setJumpAt: %@", self.tag ,name);
[self performSelectorOnMainThread:@selector(setImage:) withObject:a waitUntilDone:NO];
[self  setNeedsDisplay];
[self setNeedsLayout];}
类播放器包含片的NSMUTABLEARAY

- (void) timer_Tick{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
        [piece setJumpAt:frame++];
        [piece setNeedsDisplay];
        if (frame == len)
            frame = 0;
    dispatch_async(dispatch_get_main_queue(), ^{
    });
});}
类JumpThread包含用于设置工件图像的NSTimer

- (void) timer_Tick{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
        [piece setJumpAt:frame++];
        [piece setNeedsDisplay];
        if (frame == len)
            frame = 0;
    dispatch_async(dispatch_get_main_queue(), ^{
    });
});}
我正常运行代码,但在mainview中工件的图像不变,
对不起,我的英语不太好。

UIImageView
可以使用一组UIImages和合适的动画持续时间设置图像动画

//self is an UIImageView instance
NSArray images = [...]; // your frames
self.animationImages = images;
self.animationDuration = 2.0f // 2.0s
[self startAnimating];

最后一个
dispatch\u async()
没有向主线程分派任何内容,我不知道为什么要调用
setNeedsDisplay
setNeedsLayout
。总之,这似乎是一种笨拙且容易出错的做事方式——使用计时器和调度队列等等。你是否考虑过使用专门针对精灵和游戏的库,例如?不,我不使用SpriteKit,