7

cell.image = an animated gif file(セルは)を使用していUITableViewCellます。ただし、アニメーションはしません。修正する方法はありますか?

4

5 に答える 5

16

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];
于 2009-06-10T01:36:56.133 に答える
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
于 2009-06-10T01:16:38.577 に答える
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];
    }  
于 2016-01-12T11:06:04.120 に答える
1

アニメーション GIF ファイルの表示をサポートするのは、UIWebView のみです。

于 2010-01-05T13:45:52.063 に答える
-2

あなたの唯一の選択肢は、ビューでgifをレンダリングする独自のメカニズムをコーディングするか、Appleが修正するのを待つことです.

于 2009-06-10T00:37:45.550 に答える