samedi 27 juin 2015

Update image of UIImageView in NSmutableArray?

I have:

Class Piece inherit 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];}

Class Player contain NSMutableArray of Piece;

Class JumpThread contain NSTimer use to set image of Piece;

- (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(), ^{
    });
});}

I run code normal, but image of Piece not change in mainview, Sorry, I'm not so good at English.

Aucun commentaire:

Enregistrer un commentaire