哪个PHAssetCollection用于保存图像?

在iOS 8的Photos.framework中,我试图将UIImage保存到用户的照片库中,就好像您可以在Safari中长按图片并select“保存图像”一样。 在iOS 7中,只需调用ALAssetLibrary的writeImageToSavedPhotosAlbum:metadata:completionBlock

对于iOS 8,我们需要select一个资产集合来添加一个PHAsset,但是我不能确定哪一个PHAssetCollection最接近于保存到用户的“相机胶卷”(尽pipe在iOS中没有一个8)

 [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ PHAssetChangeRequest *newAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image]; newAssetRequest.creationDate = time; newAssetRequest.location = location; PHObjectPlaceholder *placeholderAsset = newAssetRequest.placeholderForCreatedAsset; PHAssetCollectionChangeRequest *addAssetRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:WHICH_ASSET_COLLECTION]; addAssetRequest addAssets:@[placeholderAsset]; } completionHandler:^(BOOL success, NSError *error) { NSLog(@"Success: %d", success); }]; 

我尝试访问“最近添加”的智能相册,但它不允许添加新的内容。

你不需要搞乱PHAssetCollection。 只需添加:

  [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:<#your photo here#>]; } completionHandler:^(BOOL success, NSError *error) { if (success) { <#your completion code here#> } else { <#figure out what went wrong#> } }]; 

其实在8.1的相机胶卷回来了。 这是SmartAlbumUserLibrary子types的智能相册。