DKImagePickerController
DKImagePickerController copied to clipboard
'image' property inside 'DKAsset' is nil
Under the DKImagePickerController's didSelectAssets code block the image property inside DKAsset is nil
pickerController.didSelectAssets = { (assets: [DKAsset]) in print(assets.first?.image) //prints nil }
Yes, exactly. It doesnt work as exzpected.
Under the DKImagePickerController's didSelectAssets code block the image property inside DKAsset is nil pickerController.didSelectAssets = { (assets: [DKAsset]) in print(assets.first?.image) //prints nil }
I tried this solution and it worked.
class func getUIImage(asset: PHAsset) -> UIImage? {
var img: UIImage?
let options = PHImageRequestOptions()
options.deliveryMode = .highQualityFormat
options.isSynchronous = true // Set it to false for async callback
let imageManager = PHCachingImageManager()
imageManager.requestImage(for: asset, targetSize: CGSize(width: asset.pixelWidth, height: asset.pixelHeight), contentMode: .aspectFill, options: options) { image, info in
img = image
}
return img
}