我在我的应用中使用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;
}