gpt4 book ai didi

ios - iphone SDWebImage 调整缓存图像的大小

转载 作者:行者123 更新时间:2023-12-01 18:27:41 24 4
gpt4 key购买 nike

我正在从 SBJson 解析器解析 json 并成功在 TableView 中显示它。我正在使用 SDWebImage 缓存图像以通过使用

  UIImageView *thumbImg = [[UIImageView alloc] initWithFrame:CGRectMake(5, 3, 50, 50)];
thumbImg.tag = 1;
thumbImg.contentMode = UIViewContentModeScaleAspectFill;
thumbImg.layer.cornerRadius = 10;
thumbImg.layer.masksToBounds = YES;
thumbImg.layer.borderColor = [UIColor lightGrayColor].CGColor;
thumbImg.layer.borderWidth = 1.0;
[cell.contentView addSubview:thumbImg];

[thumbImg setImageWithURL:[NSURL URLWithString:myObj.thumbnailURL]
placeholderImage:[UIImage imageNamed:@"Icon.png"]
success:^(UIImage *image) {
NSLog(@"success");
}
failure:^(NSError *error) {
NSLog(@"write error %@", error);
}];

它在我的 50x50 ImageView 中完美显示。但是缩略图的大小大约为 400x600。因此,由于在 imageview 中加载了大图像缩略图,我的 tableview 滚动非常缓慢。如何在缓存之前调整 SDWebImage 获取的图像的大小,以便下次从缓存加载时加载小尺寸图像。我有调整图像大小的功能,但不知道在哪里添加该代码。我试图通过给出我在成功 block 中获得的图像指针,但它没有效果。

谢谢

最佳答案

这里!

该库将 SDWebImage 与 Resize 库集成

https://github.com/toptierlabs/ImageCacheResize

关于ios - iphone SDWebImage 调整缓存图像的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11930923/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com