我希望从PHCachingImageManager
清除缓存,因为每当我获取新的高分辨率图像时,它会将内存增加大约3-4 Mb,具体取决于图像的大小,并最终导致应用崩溃。
这是我用来缓存图片的代码:
PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
options.synchronous = YES;
options.networkAccessAllowed = YES;
self.cachingManager = [PHCachingImageManager new];
self.cachingManager.allowsCachingHighQualityImages = YES;
[self.cachingManager startCachingImagesForAssets:self.allAssets targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeDefault options:options];
这就是我要求提供图像的方式:
[self.cachingManager requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeDefault options:options resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
imageView.image = result;
}];