2009-06-10 20 views

risposta

-2

Le tue uniche scelte sono di codificare il proprio meccanismo di rendering della gif in una vista o attendere che Apple la risolva.

2

In iPhone OS 3.0, cell.image non è più supportato. Invece, le celle hanno una proprietà imageView, che ti dà un po 'più di flessibilità. È possibile dividere la gif animata fino in immagini separate, e poi fare questo:

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

UIImageView fornisce le API necessarie per produrre il proprio animazioni in questo modo:

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

Questa è una risposta utile, ma il codice più preciso dovrebbe dire: ' UIImageView * animatedImageView; animatedImageView.animationImages = ...; animatedImageView.animationDuration = ...; ...; ' – Neeku

1

Solo UIWebView supporta la visualizzazione di un animato File GIF.

1

Potete vedere il seguente codice Spero che sarà utile a voi ...

1. Rimuovere il codice di animazione in cellforatindexpath

2. animato quando cella visualizza

3. animazione stop, nascondendo le cellule

4. migliorerà le prestazioni di App

5. Salva più memoria

-(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]; 
    } 
Problemi correlati