Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用SDWebimage通过url逐个下载图像_Ios_Objective C_Sdwebimage - Fatal编程技术网

Ios 使用SDWebimage通过url逐个下载图像

Ios 使用SDWebimage通过url逐个下载图像,ios,objective-c,sdwebimage,Ios,Objective C,Sdwebimage,我需要从Url的数组下载图像,一个接一个,一次显示所有图像。 我有一个10个URL的数组,我只需要一个接一个地下载图像,并一次显示。 我正在使用SDWebImage下载图像。 请帮帮我 谢谢。你可以试试这样的 -(void)downloadImage { if self.urlArray.count > 0) { NSURL *url = [NSURL URLWithString:[self.urlArray firstObject]]; SD

我需要从Url的
数组
下载图像,一个接一个,一次显示所有图像。
我有一个10个URL的数组,我只需要一个接一个地下载图像,并一次显示。
我正在使用
SDWebImage
下载图像。 请帮帮我


谢谢。

你可以试试这样的

-(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
数组包含您下载的所有图像

在获得
urlArray
中的所有字符串url后调用此方法


希望这将对您有所帮助。

这是您使用Swift中的SDWebImage将图像作为独立图像下载的方式

import SDWebImage

let downloader = SDWebImageManager()

downloader.imageDownloader?.downloadImage(with: URL(string: imageUrl), options: .highPriority, progress: { 
        (receivedSize, expectedSize, url) in
        // image is being downloading and you can monitor progress here
            }, completed: { (downloadedImage, data, error, success) in
                print(downloadedImage, data, success)
                //image is downloaded and ready to use
            })

你试过什么?
Swift
Objective-C
?@Nirav,我用的是Objective-C@PayalManiyar我尝试使用SDWebImages从阵列加载图像,并希望将该图像逐个存储在另一个阵列中。请将您的代码粘贴到此处。您的url不包含问题所在的图像。谢谢Nirav,我找到了解决方案。您尝试了什么?