我正在使用以下代码将图像保存到我在 iOS 照片库中创建的自定义文件夹中:
我收到此错误:Error Domain=NSCocoaErrorDomain Code=-1 "(null)"
谁能帮我解决这个问题?
+(BOOL)saveToAlbumNSString*)albumName imageUIImage*)image{
__block PHFetchResult *photosAsset;
__block PHAssetCollection *collection;
__block PHObjectPlaceholder *placeholder;
__block BOOL retStat = false;
NSData *newImageSize = UIImageJPEGRepresentation(image, 1);
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *assetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:[UIImage imageWithData:newImageSize]];
placeholder = [assetRequest placeholderForCreatedAsset];
photosAsset = [PHAsset fetchAssetsInAssetCollection:[self findAlbumAssetCollection:albumName] options:nil];
PHAssetCollectionChangeRequest *albumChangeRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:collection
assets:photosAsset];
[albumChangeRequest addAssets[placeholder]];
} completionHandler:^(BOOL success, NSError *error) {
if (success){
retStat = true;
}
else{
NSLog(@"%@", error);
}}];
}
在此处回答,以便有人可以在 google 搜索结果中找到此问题并节省我浪费的时间:如果您在创建 Assets 时遇到此错误,请检查您的手机存储空间。我收到此错误是因为我的手机有 0 字节(是的,0 字节)可用存储空间,这是另一个无提示错误的传播。
关于ios - 使用 phphotolibrary 将图像保存到自定义图库文件夹 - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33018726/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |