有没有办法将实时照片保存到照片库?

2023-11-26

我将存储的图像和视频文件传递到:PHLivePhoto.requestLivePhotoWithResourceFileURLs并得到一个PHLivePhoto我可以显示的对象PHLivePhotoView。但我想知道,一旦我有了PHLivePhoto有没有办法将其保存到照片库?


    NSURL *photoURL = ...;
    NSURL *videoURL = ...;   

    [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
            PHAssetCreationRequest *request = [PHAssetCreationRequest creationRequestForAsset];


            //These types should be inferred from your files

            //PHAssetResourceCreationOptions *photoOptions = [[PHAssetResourceCreationOptions alloc] init];
            //photoOptions.uniformTypeIdentifier = @"public.jpeg";

            //PHAssetResourceCreationOptions *videoOptions = [[PHAssetResourceCreationOptions alloc] init];
            //videoOptions.uniformTypeIdentifier = @"com.apple.quicktime-movie";

            [request addResourceWithType:PHAssetResourceTypePhoto fileURL:photoURL options:nil /*photoOptions*/];
            [request addResourceWithType:PHAssetResourceTypePairedVideo fileURL:videoURL options:nil /*videoOptions*/];

        } completionHandler:^(BOOL success, NSError * _Nullable error) {
            NSLog(@"success? %d, error: %@",success,error);
        }];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

有没有办法将实时照片保存到照片库? 的相关文章

随机推荐