如果您使用 ALAssetsLibrary 来管理您的应用程序照片,那么它们将始终显示在已保存的照片下。根据 Apple Docs,ALAssetsLibrary 的目的是
You use it to retrieve the list of all asset groups and to save images and videos into the Saved Photos album.
如果您只需要在您的应用程序中访问您的图像,您可以处理阅读写作,并自己呈现它们。这将阻止他们出现在相机角色或保存的照片中。
//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
}