包含如何将图像从iCarousel的特定索引写入文件?

时间:2015-05-12 12:26:04

标签: ios iphone file uiimageview icarousel

我在我的应用中使用iCarousel查看,此处我以幻灯片形式显示大量图片,

我想在icarousel的特定索引处将特定图像写入文件(NSDocument目录)。请帮忙解决这个问题。

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{


    NSURL *url;
    if([[NSUserDefaults standardUserDefaults]boolForKey:@"BASICDEALER_IMAGE"]==YES)
    {
               url= [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",IMAGE_REPOSITORY,[_mArImageURLs objectAtIndex:index]]];
    }
    else{
               url= [NSURL URLWithString:[NSString stringWithFormat:@"%@",[_mArImageURLs objectAtIndex:index]]];
    }

    // 2
    NSURLSessionDownloadTask *downloadPhotoTask = [[NSURLSession sharedSession]
                                               downloadTaskWithURL:url completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) 
   {
        // 3

       UIImage *downloadedImage = [UIImage imageWithData: [NSData dataWithContentsOfURL:location]];
       Placeholdimg =[[UIImageView alloc]initWithImage:downloadedImage];

     }];

    // 4    
    [downloadPhotoTask resume];


    [view addSubview:Placeholdimg];
    Placeholdimg.contentMode=UIViewContentModeScaleAspectFill;
    view.contentMode  = UIViewContentModeScaleAspectFill;
     return view;

}

0 个答案:

没有答案