I'm using the BSImagePicker
Image Picker controller (See here)
The image picker controller returns PHAsset rather than UIImage, so I found out how to convert PHAsset to UIImage using this function:
func getAssetThumbnail(asset: PHAsset) -> UIImage {
let manager = PHImageManager.default()
let option = PHImageRequestOptions()
var thumbnail = UIImage()
option.isSynchronous = true
manager.requestImage(for: asset, targetSize: CGSize(width: 100, height: 100), contentMode: .aspectFit, options: option, resultHandler: {(result, info)->Void in
thumbnail = result!
})
return thumbnail
}
Issue is that, I want to return the targetSize of PHImageManagerMaximumSize
. Althought when this happens, I get an errorrThis application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
The error doesn't occur when I set targetSize
to CGSize(width: 100, height: 100)