我在由PHContentEditingOutput
. 当我像这样加载数据UIImage
并保存它时 - 它可以工作。
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
NSData *data = [NSData dataWithContentsOfURL:contentEditingOutput.renderedContentURL]
UIImage *image = [UIImage imageWithData:data];
[PHAssetChangeRequest creationRequestForAssetFromImage:image];
} completionHandler:^(BOOL success, NSError *error) {
...
}];
但是当我尝试使用 url 方法时它失败了:
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
[PHAssetChangeRequest creationRequestForAssetFromImageAtFileURL:contentEditingOutput.renderedContentURL];
} completionHandler:^(BOOL success, NSError *error) {
...
}];
错误:
Error Domain=NSCocoaErrorDomain Code=-1 “操作无法完成。(Cocoa 错误 -1。)”
更新:
当我尝试保存修改时出现同样的错误。
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *request = [PHAssetChangeRequest changeRequestForAsset:asset];
request.contentEditingOutput = contentEditingOutput;
} completionHandler:^(BOOL success, NSError *error) {
...
}];
该方法适用于视频 ( creationRequestForAssetFromVideoAtFileURL:
),但不适用于图像。什么地方出了错?