This is how my project works, I have a UIScrollView below the addButton button, when I click on it, it is redirected to AGImagePickerController (for those who do not know AGImagePickerController, this is a set of images). Then you clicked the images (one or more images). When you press DONE , it will save the images to NSCachesDirectory . It will display the image selected in the UIScrollView (which can be deleted). When you click addButton again, it will show you the picked image some time ago with checkMark .
PROBLEM: When I delete an image in UIScrollView , the image that was deleted in AGImagePickerController is still checked . AGImagePickerController when deleted in UIScrollView , will also be deleted in AGImagePickerController .
What I wanted to do was save his image using a URL , then put it in a folder inside my NSCachesDirectory so I can easily download it, but I donβt know where to start, since Im organizes my images in UIScrollView by integer names. Hope someone can suggest what to do. Thank you very much.
NOTE. . For those who have read this, please comment on which part of the code you want to place here, or the part that you have a problem with. Thanks again.
CODE:
Here is my part of 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]; }
Then in my AGIPCAssetsController.m (where part of the checkMark image is 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]; }); }); }