嗨,我真的很难保存我的NSDocumentDirectory
.ImAGImagePicker
顺便说一句。是的,我能够将其保存在NSDocumentDirectory
. 但是如何唯一地保存它们(就它们自己而言,然后将它们的名称转换为oneSlotImages
)或使用它们的唯一 ID 保存它们然后将它们加载回来。抱歉,我对这UIImagePickerControllerMediaURL
件事有点陌生。,我认为这将是我解决其他问题的方法,因为在保存时不重叠它们。如何使用他们的唯一 ID 或UIImagePickerControllerMediaURL
.
for (int i = 0; i < info.count; i++) {
NSLog(@"%@", [info objectAtIndex:i]);
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask ,YES );
NSString *documentsDir = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"oneSlotImages%d.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)];
NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:savedImagePath atomically:YES];
谢谢您的帮助。非常感激。