gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 03:05:32 26 4
gpt4 key购买 nike

我将存储的图像和视频文件传递给:PHLivePhoto.requestLivePhotoWithResourceFileURLs 并获取可以在 PHLivePhotoView 中显示的 PHLivePhoto 对象。但我想知道,一旦我有了 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);
}];

关于ios - 有没有办法将实时照片保存到照片库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32893993/

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