これが私のプロジェクトの仕組みです。UIScrollView
下にはボタンがaddButton
あり、クリックするとリダイレクトされますAGImagePickerController
(AGImagePickerControllerを知らない人にとっては、複数の画像ピッカーです)。次に、画像(単一または複数の画像)をクリックしました。を押すDONE
と、画像が に保存されNSCachesDirectory
ます。UIScrollView
(削除可能)で選択した画像が表示されます。addButton
もう一度を押すpicked
と、少し前の画像が で表示されますcheckMark
。
問題:静止画UIScrollView
で削除された画像の画像を削除すると。で削除する場合は、 で削除する必要もあります。AGimagePickerController
checked
UIScrollVIew
AGimagePickerController
私がやりたかったのは、その画像を保存してから、簡単にロードできるようにURL
内部のフォルダーに配置することですが、整数で名前を付けNSCachesDirectory
て画像を配置しているため、どこから始めればよいかわかりません。UIScrollView
誰かが何をすべきかを提案してくれることを願っています。どうもありがとうございます。
注:これを読んだ人は、ここに投稿してほしいコードの部分、または問題がある部分についてコメントしてください。ありがとうございました。
コード:
これが私のDONE
部分です:
for (int i = 0; i < info.count; i++) {
//NSLog(@"%@", [info objectAtIndex:i]);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask ,YES );
NSString *documentsDir = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"oneSlotImages%u.png", i]];
ALAssetRepresentation *rep = [[info objectAtIndex: i] defaultRepresentation];
UIImage *image = [UIImage imageWithCGImage:[rep fullResolutionImage]];
//----resize the images
image = [self imageByScalingAndCroppingForSize:image toSize:CGSizeMake(256,256*image.size.height/image.size.width)];
//----fix image orientation
image = [image fixSlotOrientation];
NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:savedImagePath atomically:YES];
}
それから私の中でAGIPCAssetsController.m
(画像checkmark
部分の保存場所)
- (void)loadAssets
{
count = 0;
[self.assets removeAllObjects];
AGIPCAssetsController *blockSelf = self;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
// Where I make an array to put the `ALAsset Url`
selectedPhotos = [[NSMutableArray alloc] initWithArray:blockSelf.imagePickerController.selection];
@autoreleasepool {
[blockSelf.assetsGroup enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
// ALAssetRepresentation* representation = [result defaultRepresentation];
// NSUInteger assetindex= [blockSelf.assetsGroup numberOfAssets];
if (result == nil)
{
return;
}
AGIPCGridItem *gridItem = [[AGIPCGridItem alloc] initWithAsset:result andDelegate:blockSelf];
if(count < blockSelf.imagePickerController.selection.count)
{
if ( blockSelf.imagePickerController.selection != nil &&
[result isEqual:[selectedPhotos objectAtIndex:count]])
{
gridItem.selected = YES;
count++;
NSLog(@" %@",result);
}
}
[blockSelf.assets addObject:gridItem];
}];
}
dispatch_async(dispatch_get_main_queue(), ^{
[blockSelf reloadData];
});
});
}