gpt4 book ai didi

ios - 如何从 SDWebImage 获取图像大小?

转载 作者:行者123 更新时间:2023-11-28 08:38:21 27 4
gpt4 key购买 nike

我正在使用 SDWebImage 从 url 获取图像。我想获取远程图像的大小以便进行一些布局计算。由于我只知道图像的 url,如何从 SDWebImage 对象中获取它?

最佳答案

请试试这个,它可能适合你

-(UIImage *)downloadImageAsync:(NSString *)imageKey
{
NSLog(@"image key : %@",imageKey);
__block UIImage *returnedImage;
SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadWithURL:[NSURL URLWithString:imageKey] options:0 progress:^(NSUInteger receivedSize, long long expectedSize){
NSLog(@"received size %d expected size %lld", receivedSize, expectedSize);

}completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType,BOOL finished){
if(image && finished) {
returnedImage = image;
}
}];

if(returnedImage == nil) {
NSLog(@"Returned Image Nil");
}
return returnedImage;
}

关于ios - 如何从 SDWebImage 获取图像大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37072390/

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