繁体   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