Get the local file path of a PHAsset

后端 未结 6 1637
后悔当初
后悔当初 2021-02-18 21:31

I have a photo I want my user to be able to share on Instagram and I need to get the local file directory of the photo.

However I am fetching my images as a PHAsset (not

6条回答
  •  隐瞒了意图╮
    2021-02-18 22:25

    func getImagesFromAsset(anAsset: PHAsset) {
        PHImageManager.default().requestImage(for: anAsset, targetSize: CGSize(width: 600, height: 600), contentMode: .aspectFill, options: nil, resultHandler: { (image, info) in
            //resultHandler have info ([AnyHashable: Any])
            print(info!["PHImageFileURLKey"])
            if let img = image {
                self.imgv.image = img
            }
        })
    }
    

    this might help paste this in you CellForRowAt method and pass the PHAsset in argument.

提交回复
热议问题