[英]Gif Crashing on iOS device
Gif在模擬器上運行平穩,但由於內存而在設備中崩潰。 如何處理。 我在Google上搜索了很多,但沒有找到任何解決方案。
以下是我用來加載Gif的代碼
NSURL *url = [[NSBundle mainBundle] URLForResource:[utility getString] withExtension:@"gif"];
self.img.image = [UIImage animatedImageWithAnimatedGIFURL:url];
提前致謝
使用來自Github的FLAnimatedImage庫:-使用https://github.com/Flipboard/FLAnimatedImage它易於使用且對內存友好。
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.