【问题标题】:Gif Crashing on iOS deviceiOS 设备上的 Gif 崩溃
【发布时间】:2015-10-22 17:44:43
【问题描述】:

Gif 在模拟器上运行流畅,但由于内存问题在设备中崩溃。如何处理这个。我用谷歌搜索了很多,但没有找到任何解决方案。

以下是我用来加载 Gif 的代码

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

提前致谢

【问题讨论】:

  • 您是否将其加载到 webview 中?或者你有一系列加载到 imageview 中的 uiimage?
  • 我将这个库用于 gif,效果很好。 github.com/rs/SDWebImage
  • @gottlieb 以下是我用来加载 Gif NSURL *url = [[NSBundle mainBundle] URLForResource:[utility getString] withExtension:@"gif"]; self.img.image = [UIImage animatedImageWithAnimatedGIFURL:url];

标签: ios objective-c image gif


【解决方案1】:

据我所知,由于内存压力和内存使用量的大幅增加,它会崩溃。

查看这些链接,它可能会对您有所帮助link1link2!!link3!!

【讨论】:

    【解决方案2】:

    使用 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]; 
    

    这是一个经过充分测试的组件。

    【讨论】:

      猜你喜欢
      • 2012-08-30
      • 2012-12-06
      • 2018-03-02
      • 2019-12-30
      • 1970-01-01
      • 1970-01-01
      • 2014-11-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多