iOS解决SDWebimage加载高分辨率大图crash的问题。

2021-07-29  本文已影响0人  神一样的队友

参考文章:https://blog.csdn.net/fengzhixinfei/article/details/87912102

在APPDelegate中设置相关参数。

- (void)imageLoadingSettings {

    [SDImageCache sharedImageCache].config.maxCacheAge = 3600 * 24 * 7;

    [SDImageCache sharedImageCache].maxMemoryCost = 1024 * 1024 * 20;

    [SDImageCache sharedImageCache].config.shouldCacheImagesInMemory = NO;

    [SDImageCache sharedImageCache].config.shouldDecompressImages = NO;

    [SDWebImageDownloader sharedDownloader].shouldDecompressImages = NO;

    [SDImageCache sharedImageCache].config.diskCacheReadingOptions = NSDataReadingMappedIfSafe;

}

在使用时加载方法的options中设置SDWebImageScaleDownLargeImages

[_billImageView sd_setImageWithURL:url placeholderImage:image options:SDWebImageRetryFailed|SDWebImageScaleDownLargeImages|SDWebImageRefreshCached];

上一篇下一篇

猜你喜欢

热点阅读