2009-06-10 102 views

回答

-2

你唯一的选择是编码自己的机制,在视图中呈现GIF或等待苹果来修复它。

2

在iPhone OS 3.0中,不再支持cell.image。相反,单元格有一个imageView属性,它给了你更多的灵活性。您可以拆分GIF动画成单独的图像,然后做到这一点:

anImageView *UIImageView = [[UIImageView alloc] init]; 
anImageView.animationImages = imagesArray; //this is an array of UIImages you have to create 
15

UIImageView提供了必要的API来制作自己的动画这样的:

UIImage *frame1 = [UIImage imageNamed:@"frame1.png"]; 
UIImage *frame2 = [UIImage imageNamed:@"frame2.png"]; 
UIImage *frame3 = [UIImage imageNamed:@"frame3.png"]; 
UIImage *frame4 = [UIImage imageNamed:@"frame4.png"]; 


UIImageView.animationImages = [[NSArray alloc] initWithObjects:frame1, frame2, frame3, frame4, nil]; 
UIImageView.animationDuration = 1.0 //defaults is number of animation images * 1/30th of a second 
UIImageView.animationRepeatCount = 5; //default is 0, which repeats indefinitely 
[UIImageView startAnimating]; 

//[uiImageView stopAnimating]; 
+0

这是一个有用的答案,但更精确的代码应该说:' * UIImageView的animatedImageView; animatedImageView.animationImages = ...; animatedImageView.animationDuration = ...; ...;` – Neeku 2014-02-21 11:32:49

1

能否请你看下面的代码,我希望这将有助于你...

1 cellforatindexpath删除动画代码

2.动画时,电池显示

3.停止动画,而隐藏在细胞

4.将改进的应用程序

5.性能保存更多的内存

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ 
    NSArray *myImageArray = [NSArray arrayWithObjects: 
          [UIImage imageNamed:@"image1.png"], 
          [UIImage imageNamed:@"image2.png"], 
          [UIImage imageNamed:@"image3.png"], 
          [UIImage imageNamed:@"image4.png"], 
          [UIImage imageNamed:@"image5.png"],nil]; 

    [cell.imageView setAnimationImages:myImageArray]; 
    cell.imageView.animationDuration = 4.0; 
    cell.imageView.animationRepeatCount = 1; 
    [cell.imageView startAnimating]; 
    } 

    -(void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ 
    [cell.imageView stopAnimating]; 
    [cell.layer removeAllAnimations]; 
    }