gpt4 book ai didi

ios - 如何像 ALAssetsLibrary 一样使用 PHPhotoLibrary

转载 作者:技术小花猫 更新时间:2023-10-29 10:33:51 25 4
gpt4 key购买 nike

对于 iOS9,ALAssetsLibrary 已弃用。那么如何将其更改为 PHPPhotoLibrary 而不是 ALAssets

if (RecordedSuccessfully && recording == NO) {
//----- RECORDED SUCESSFULLY -----
NSLog(@"didFinishRecordingToOutputFileAtURL - success");
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:outputFileURL])
{
[library writeVideoAtPathToSavedPhotosAlbum:outputFileURL
completionBlock:^(NSURL *assetURL, NSError *error)
{
if (error)
{

}
}];
}

//我试过了,但是没用

[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{

PHAssetChangeRequest* createAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:outputFileURL];

NSParameterAssert(createAssetRequest);
}
completionHandler:^(BOOL success, NSError *error) {}];
}
}

最佳答案

// Save to the album
__block PHObjectPlaceholder *placeholder;

[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest* createAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:outputFileURL];
placeholder = [createAssetRequest placeholderForCreatedAsset];

} completionHandler:^(BOOL success, NSError *error) {
if (success)
{
NSLog(@"didFinishRecordingToOutputFileAtURL - success for ios9");
}
else
{
NSLog(@"%@", error);
}
}];

关于ios - 如何像 ALAssetsLibrary 一样使用 PHPhotoLibrary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33500266/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com