kee*_*n3d 8 cocoa-touch ios ios9.1 phlivephoto
我将存储的图像和视频文件传递给:
PHLivePhoto.requestLivePhotoWithResourceFileURLs并获取PHLivePhoto我可以显示的对象PHLivePhotoView.但我想知道,一旦我PHLivePhoto有一个方法将它保存到照片库?
jlw*_*jlw 15
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);
}];
Run Code Online (Sandbox Code Playgroud)
斯威夫特3:
PHPhotoLibrary.shared().performChanges({
let request = PHAssetCreationRequest.forAsset()
request.addResource(with: .photo, fileURL: photoURL, options: nil)
request.addResource(with: .pairedVideo, fileURL: videoURL, options: nil)
}) { (success, error) in
print(success)
print(error?.localizedDescription ?? "error")
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4708 次 |
| 最近记录: |