我通过使用SDWebImageManager
从网站下载多个图像文件。 我可以下载具有像2050 x 3500
这样的分辨率的文件。下面是我为同一SDWebImageManager崩溃时下载大分辨率图像文件
SomeObj *limgObj = [imageinfoArray objectAtIndex:count];
__weak UIImageView *thumbImg_ = bannerImgView;
__weak typeof(self) weakSelf = self;
SDWebImageManager *manager = [SDWebImageManager sharedManager];
manager.delegate = weakSelf;
if([limgObj.imageUrl length] > 0) {
[manager downloadWithURL:[NSURL URLWithString:limgObj.imageUrl] options:0 progress:^(NSUInteger receivedSize, long long expectedSize)
{
[MMProgressHUD showWithTitle:@"" status:@"Processing.."];
} completed:^(UIImage *image,NSError *error, SDImageCacheType cacheType, BOOL finished) {
thumbImg_.image = image;
[MMProgressHUD dismiss];
}];
}
如果图像的宽度或高度的代码比2000更大的是我处理它的委托方法如下
- (UIImage *)imageManager:(SDWebImageManager *)imageManager transformDownloadedImage:(UIImage *)image withURL:(NSURL *)imageURL
{
NSLog(@"ORIGINAL - > width -> %f height - >%f", image.size.width, image.size.height);
if (image.size.width > 2000 && image.size.width < 3000) {
CGSize newSize = CGSizeMake(image.size.width/1.5, image.size.height/1.5);
UIGraphicsBeginImageContextWithOptions(newSize, NO, 1.0);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
NSLog(@"NEW - > width -> %f height - >%f", newImage.size.width, newImage.size.height);
UIGraphicsEndImageContext();
return newImage;
}.....>Multiple cases handled for bigger images omitted to make small code here
return image;
}
提到缓存效果之前降级它不过像4961 × 7016
图片这只是557kb
的大小我的应用程序崩溃与内存压力警告甚至没有调用我的代理功能transformDownloadedImage
并给我机会降级之前缓存。
请帮我弄清楚我在这里做错了什么,以及为什么SDWebImageManager
无法在第一时间下载大分辨率图像。
由于
这个信息将是有效早在2007年,但在这里是2015年和iPhone 6+具有分辨率超过2K像素,甚至是iPhone 4S支持4K纹理。 – Andy
该文档的部分已在不到5个月前更新(请参阅我发布的链接:“更新:2015-01-12”)。一个很好的建议,阅读更多的苹果文档之前,评价其他职位。 – Elidemir
我一直在阅读他们过去5年的文档。自从iOS 3.0或更早以来,该段已存在多年。你通常应该尽量减少设备上的所有重量,但1024不再是限制。 – Andy