2016-08-27 4 views
0

J'ai la méthode suivante pour effectuer affichage de l'image animée:Obtenir EXC_BAD_ACCESS lors de l'utilisation FLAnimatedImage

-(void) setTheGifHeigt:(int)screenHeight andWidth:(int)screenWidth andSize:(int)size{ 
image = [[FLAnimatedImage alloc] initWithAnimatedGIFData:[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"mygif" ofType:@"gif"]]]; 
imageView = [[FLAnimatedImageView alloc] init]; 
imageView.loopCompletionBlock(0); 
imageView.animatedImage = image; 

imageView.frame = CGRectMake((screenWidth/2) - (size/2), (screenHeight/2) - (size/2), size, size); 
[self.view addSubview:imageView]; 

} 

Mon but est simple, je veux que mon gif jouer une fois. Mais quand j'ajoute méthode "looopCompletionBlock" je reçois l'erreur suivante:

Thread1: EXC_BAD_ACCESS (Code = 1, adresse = 0x10)

En attente de votre aide, merci :)

Répondre

1

Vous devriez essayer fournir un bloc réel au lieu de zéro, comme indiqué dans le fichier d'en-tête:

@property (nonatomic, copy) void (^) (NSUInteger loopCountRemaining) loopCompletionBlock

Cependant, en regardant à la source FLAnimatedImage la seule utilisation loopCountRemaining trouvée est dans https://github.com/Flipboard/FLAnimatedImage/blob/06d071f674682e90409c648aab60dd50be68bc0f/FLAnimatedImage/FLAnimatedImageView.m#L394, donc le problème ne réside probablement pas ici.

+0

Que voulez-vous dire par bloc réel, pouvez-vous donner un exemple? – phantom

+0

Ceci est un bloc:^void (NSUInteger i) {NSLog (@ "test"); } –