使用SDWebimage下载带有网址的一对一图像 [英] Download Images One By One with url using SDWebimage
本文介绍了使用SDWebimage下载带有网址的一对一图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从Url的 Array
下载图像,并一次显示所有内容.前任.我有10个URL的数组,我只需要一个一个下载图像,然后一次显示.我正在使用 SDWebImage
下载图像.请帮助我.
I need to Download images from Array
of Url's, one by one and Display all at a Time.
Ex. I have an array of 10 URL's and I need to Download image One By One only, and display at a time.
I am Using SDWebImage
for Download Images.
Please Help me.
谢谢.
推荐答案
您可以尝试类似
-(void)downloadImage {
if self.urlArray.count > 0) {
NSURL *url = [NSURL URLWithString:[self.urlArray firstObject]];
SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadImageWithURL:imageURL
options:0
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
// progression tracking code
}
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (image) {
[self.imageArray addObject:image];
[self.urlArray removeObjectAtIndex:0];
[self downloadImage];
}
else {
[self downloadImage]; //try download once again
}
}];
}
else {
NSLog(@"All Images are downloaded do what u want")
}
}
注意:-,这里的 urlArray
是字符串url的数组,而 imageArray
数组包含您已下载的所有图像.
Note:- Here urlArray
is array of string url and imageArray
array contain all the image that you have download.
调用此方法.
希望这会对您有所帮助.
Hope this will help you.
这篇关于使用SDWebimage下载带有网址的一对一图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文