【发布时间】:2018-09-29 13:21:01
【问题描述】:
PHPhotoLibrary.shared().performChanges({ () -> Void in
let request = PHAssetCreationRequest.forAsset()
request.addResource(with: .pairedVideo, fileURL: videoURL, options: nil)
request.addResource(with: .photo, fileURL: imageURL, options: nil)}, completionHandler: { (result : Bool, error : Error?) -> Void in
if result {
NSLog("save to camera roll as live photo")
} else {
if error != nil {
print("something wrong when saving : %@", error!)
}
}
})
但是,Error Domain=NSCocoaErrorDomain Code=-1 "(null)"。如何解决?
【问题讨论】:
-
你为什么用
PHAssetResourceType(rawValue: 9)而不是“.pairedVideo”?我也几乎不建议你安全地打开你的变量,相信我你会做噩梦。在调试模式下检查所有变量,nil? -
是的,我编辑了它,仍然......不为零。
-
github.com/genadyo/LivePhotoDemo 。我希望你看看这个例子,很明显你保存的文件有问题,而不是你想的代码中的问题
-
看看这个answer
标签: swift phlivephoto