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

参考文章: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];

你可能感兴趣的:(iOS解决SDWebimage加载高分辨率大图crash的问题。)