嗨我真的很難節省我的NSDocumentDirectory
。我使用AGImagePicker
順便說一句。是的,我可以保存在NSDocumentDirectory
。但是,如何將它們保存爲唯一的(就其自身而言,然後將它們的名稱轉換爲oneSlotImages
),或者將它們保存爲唯一的ID,然後將它們加載回去。對不起,我有點新的UIImagePickerControllerMediaURL
事情,我認爲這將是我的解決方案,我的另一個問題是保存時不重疊他們。如何使用其唯一的ID或UIImagePickerControllerMediaURL
進行保存。唯一地保存在NSDocumentDirectory
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];
感謝您的幫助。非常感激。
如何在我的代碼?以及如何加載它們 – Bazinga 2012-07-11 06:45:10
請參閱編輯。 – 2012-07-11 06:53:22
然後在加載時? – Bazinga 2012-07-11 06:55:04