【发布时间】:2014-12-21 00:40:54
【问题描述】:
更新/改写的问题:
在我的项目中,我使用ALAssetsLibrary-CustomPhotoAlbum。虽然它在 iOS 7 上运行良好,但在为 iOS 8 编码时我从未注意到它最终被破坏了。因无法重新创建已删除的同名文件夹而损坏。
如果它作为一个新进程启动,它将创建文件夹,如果您打开应用程序并请求照片权限。
如果我手动创建文件夹,我当前的代码仍会将照片保存到所述文件夹:
[self.library saveImage:image toAlbum:@"NamedAlbum" withCompletionBlock:^(NSError *error) {
if (error!=nil) {
NSLog(@"Big error: %@", [error description]);
}
}];
我坚持的是以下几点:
[self.library saveImage:image toAlbum:@"NamedAlbum" completion:nil failure:^(NSError *error) {
if (error!=nil) {
NSLog(@"Big error: %@", [error description]);
}
}];
它似乎改变了完成/失败阻止过程,我想不通。
我需要做什么才能将它们链接到图书馆?
任何帮助将不胜感激。
更新 12/22 似乎我在发布答案时领先于自己,这有时才有效。会继续挖掘。
// The completion block to be executed after image taking action process done
void (^completion)(NSURL *, NSError *) = ^(NSURL *assetURL, NSError *error) {
if (error) NSLog(@"!!!ERROR, write the image data to the assets library (camera roll): %@",
[error description]);
NSLog(@"*** URL %@ | %@ || type: %@ ***", assetURL, image, [assetURL class]);
};
void (^failure)(NSError *) = ^(NSError *error) {
if (error == nil) return;
NSLog(@"!!!ERROR, failed to add the asset to the custom photo album: %@", [error description]);
};
[self.assetsLibrary saveImage:image
toAlbum:albumName
completion:completion
failure:failure];
【问题讨论】:
标签: ios photo alassetslibrary