簡體   English   中英

Gif在iOS設備上崩潰

[英]Gif Crashing on iOS device

Gif在模擬器上運行平穩,但由於內存而在設備中崩潰。 如何處理。 我在Google上搜索了很多,但沒有找到任何解決方案。

以下是我用來加載Gif的代碼

NSURL *url = [[NSBundle mainBundle] URLForResource:[utility getString] withExtension:@"gif"]; 
self.img.image = [UIImage animatedImageWithAnimatedGIFURL:url];

提前致謝

據我所知,它由於內存壓力和內存使用量的大量增加而崩潰。

檢查這些鏈接,可能會幫助您link1link2 !! link3!

使用來自Github的FLAnimatedImage庫:-使用https://github.com/Flipboard/FLAnimatedImage它易於使用且對內存友好。

導入“ FLAnimatedImage.h”

導入“ FLAnimatedImageView.h”

FLAnimatedImage *image         = [FLAnimatedImage animatedImageWithGIFData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif"]]];
FLAnimatedImageView *imageView = [[FLAnimatedImageView alloc] init];
imageView.animatedImage        = image;
imageView.frame                = CGRectMake(0.0, 0.0, 100.0, 100.0); //As your Wish you can set frame
[self.view addSubview:imageView]; 

這是一個經過充分測試的組件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM