[英]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.