我能够成功地创建一个具有jpeg和mov文件的LivePhoto,并将其显示在屏幕上。
现在,我在将LivePhoto保存到库时遇到了麻烦。使用下面的代码,我收到了错误:"resource not available“。
@IBAction func exportButton(_ sender: Any) {
PHLivePhoto.request(withResourceFileURLs: [imgUrl!,videoUrl!], placeholderImage: previewImg, targetSize: CGSize.zero, contentMode: PHImageContentMode.aspectFit, resultHandler: { (livePhoto,info) -> Void in
let items = [livePhoto] as [Any]
let ac = UIActivityViewController(activityItems: items as [Any], applicationActivities: nil)
self.present(ac, animated: true)
})
}提前谢谢你!
发布于 2019-03-21 00:39:37
我能够使用下面这段代码正确地导出图像:
PHPhotoLibrary.shared().performChanges({
let creationRequest = PHAssetCreationRequest.forAsset()
let options = PHAssetResourceCreationOptions()
creationRequest.addResource(with: PHAssetResourceType.pairedVideo, fileURL: videoUrl!, options: options)
creationRequest.addResource(with: PHAssetResourceType.photo, fileURL: imgUrl!, options: options)
}, completionHandler: { (success, error) in
if error != nil {
print(error)
}
print(success)
})https://stackoverflow.com/questions/55261749
复制相似问题