我使用BSImagePicker
圖像選取器控制器()轉換PHAsset到的UIImage並顯示用戶
圖像拾取控制器返回PHAsset而不是UIImage的,所以我發現瞭如何PHAsset轉換的UIImage使用此功能:
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
}
問題是,我想回到的PHImageManagerMaximumSize
的的targetSize。 Althought發生這種情況時,我得到一個errorr This 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.
當我設置targetSize
到CGSize(width: 100, height: 100)