Reputation: 1070
Is there a way to disable the "Saved Photos" folder when saving an image?
NSData *data1 = UIImagePNGRepresentation(imageToCrop.image);
UIImage *tehnewimage = [UIImage imageWithData: data1];
[self.library saveImage:tehnewimage toAlbum:@"Databender Edits" withCompletionBlock:^(NSError *error) {
if (error!=nil) {
NSLog(@"eRrOr: %@", [error description]);
}
}];
Upvotes: 0
Views: 800
Reputation: 1099
If you are using ALAssetsLibrary to manage your apps photos, then they will always show under saved photos. According to the Apple Docs the purpose of ALAssetsLibrary is
You use it to retrieve the list of all asset groups and to save images and videos into the Saved Photos album.
If you only need your images accessible inside your app you can handle the reading writing, and presenting of them yourself. This would prevent them from showing up in the camera role or saved photos.
//WRITING TO APP DIRECTORY
NSString *directory = [NSHomeDirectory() stringByAppendingPathComponent:@"Photos/"];
if (![[NSFileManager defaultManager] fileExistsAtPath:directory]){
NSError* error;
[[NSFileManager defaultManager] createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:&error];
}
NSData *imgData = UIImagePNGRepresentation(imageToCrop.image);
NSString *imgName = @"example.png";
NSString *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:imgName];
[imgData writeToFile:pngPath atomically:YES];
//READING FROM APP DIRECTORY
NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"/Photos/"] error:NULL];
for (int i = 0; i < (int)[directoryContent count]; i++)
{
NSURL *url = [NSURL URLWithString:[NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"/Documents/Photos/%@",[directoryContent objectAtIndex:i]]]];
UIImage *image = [UIImage imageWithContentsOfFile:[url absoluteString]];
//ADD IMAGE TO TABLE VIEW OR HANDLE HOW YOU WOULD LIKE
}
Upvotes: 1