来自NSData的实时照片

时间:2016-02-23 16:56:26

标签: ios swift phlivephoto apple-live-photos

我将实时照片存储在服务器上,两个单独的文件是JPG和MOV文件。当我检索它们时,我留下了NSData,这是我的问题出现的地方,我不知道如何从这些数据中创建PHLivePhoto

如果文件捆绑在我的项目中,我将如何创建PHLivePhoto:

let imgURL = NSBundle.mainBundle().URLForResource("IMG_0001", withExtension: "JPG")!
let movURL = NSBundle.mainBundle().URLForResource("IMG_0001", withExtension: "mov")!

func makeLivePhotoFromItems(imageURL: NSURL, videoURL: NSURL, previewImage: UIImage, completion: (livePhoto: PHLivePhoto) -> Void) {
    PHLivePhoto.requestLivePhotoWithResourceFileURLs([imageURL, videoURL], placeholderImage: previewImage, targetSize: CGSizeZero, contentMode: PHImageContentMode.AspectFit) {
        (livePhoto, infoDict) -> Void in
        // for debugging: print(infoDict)
        if let lp = livePhoto {
            completion(livePhoto: lp)
        }
    }
}

 //  Credit :
   http://stackoverflow.com/questions/33990830/working-with-live-photos-in-playground

这给了我一张PHLivePhoto。我应该采取什么方法向用户显示照片?

0 个答案:

没有答案