开发者

UIImageView doesn't animate

I have the following code inside my app, but it doesn't animate the UIImageView, can anyone tell me why?

    UITableViewCell* cell = [selectedTable cellForRowAtIndexPath:selectedPath];

    NSArray* myImageArray = [NSArray arrayWithObjects:
                             [UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked117x11" ofType:@"png"]],
                             [UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked217x11" ofType:@"png"]],
                             [UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked317x11" ofType:@"png"]],
                             [UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingCh开发者_C百科ecked417x11" ofType:@"png"]],
                             [UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked517x11" ofType:@"png"]],
                             [UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked617x11" ofType:@"png"]],
                             nil];


    cell.imageView.animationImages = myImageArray;
    cell.imageView.animationDuration = 4.20;
    cell.imageView.animationRepeatCount = 1;
    [cell.imageView startAnimating];
    [NSTimer scheduledTimerWithTimeInterval:4.0
                                     target:self
                                   selector:@selector(methodToInvokeAfterAnimationIsDone)
                                   userInfo:nil
                                    repeats:NO];


You should use this:

NSArray* myImageArray = [NSArray arrayWithObjects:
                             [UIImage imageNamed:@"boxBeingChecked117x11.png"]],
                             [UIImage imageNamed:@"boxBeingChecked217x11.png"]],
                             [UIImage imageNamed:@"boxBeingChecked317x11.png"]],
                             [UIImage imageNamed:@"boxBeingChecked417x11.png"]],
                             [UIImage imageNamed:@"boxBeingChecked517x11.png"]],
                             [UIImage imageNamed:@"boxBeingChecked617x11.png"]],
                             nil];

You need to give name of the file, not the path, in imageNamed: method.


Make sure that the imageView's highlighted property is set to NO, otherwise the code you have above will not work. If you want to animate highlighted images, use highlightedAnimationImages.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜