Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.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 nsarray有许多URL,在progressview上加载_Ios_Uiprogressview - Fatal编程技术网

Ios nsarray有许多URL,在progressview上加载

Ios nsarray有许多URL,在progressview上加载,ios,uiprogressview,Ios,Uiprogressview,数组有许多URL,在progressview上加载 在进度视图上加载完整的数组如果要临时保存,请使用NSUserDefaults并设置对象,即可变数组。因此它将本地保存到您的磁盘UIProgressView*progressVieww= imagesArray = [[NSArray alloc]initWithObjects:@"http://farm3.static.flickr.com/2887/9391679341_266553bcafa_b.png",@"http://farm3.st

数组有许多URL,在progressview上加载


在进度视图上加载完整的数组

如果要临时保存,请使用NSUserDefaults并设置对象,即可变数组。因此它将本地保存到您的磁盘

UIProgressView*progressVieww=
imagesArray = [[NSArray alloc]initWithObjects:@"http://farm3.static.flickr.com/2887/9391679341_266553bcafa_b.png",@"http://farm3.static.flickr.com/2897/9391679341_26643bcafa_b.png",@"http://farm3.static.flickr.com/2887/9691679341_26643bcafa_b.png",@"http://farm3.static.flickr.com/2887/9391679341_26644bcafa_b.png",@"http://farm3.static.flickr.com/2887/9391679341_26643bcafa_b.png",@"http://farm3.static.flickr.com/2887/9391679341_26643bcafa_b.png",@"http://farm3.static.flickr.com/2887/9391679341_26643bcafa_b.png",@"http://farm3.static.flickr.com/2887/9391679344_26643bcafa_b.png", nil ];
[[UIProgressView alloc]init]; //配置进度视图并将其添加到 你的用户界面 调度异步(调度获取全局队列(调度队列优先级默认为0)^{
对于(int i=0;ii)找到了答案,感谢您的支持
 UIProgressView *progressVieww = 
   [[UIProgressView alloc] init];
// configure the progress view and add it to 
 your UI

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    for (int i=0; i<[array count]; i++)
    {
        NSError *error;
        NSArray *ipaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *idocumentsDir = [ipaths objectAtIndex:0];
        NSString *idataPath = [idocumentsDir stringByAppendingPathComponent:@"File"];
        NSLog(@"idataPath:%@",idataPath);

        //Create folder here
        if (![[NSFileManager defaultManager] fileExistsAtPath:idataPath])
        {
            [[NSFileManager defaultManager] createDirectoryAtPath:idataPath withIntermediateDirectories:NO attributes:nil error:&error];
        }
        // Image Download here
        NSString *fileName = [idataPath stringByAppendingFormat:@".jpg"];
        NSLog(@"imagePathDOWNLOAD:%@",fileName);

        _imgData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[array objectAtIndex:i]]];
        [_imgData writeToFile:fileName atomically:YES];

        // now dispatch any UI updates back to the main queue
        dispatch_async(dispatch_get_main_queue(), ^{

            [progressView setProgress: (CGFloat) (i + 1.0) / [array count] animated:YES];



            tempImg.image = [UIImage imageWithData:_imgData];
        });
    }
});