【发布时间】:2017-03-09 11:48:49
【问题描述】:
我正在使用BSImagePicker Image Picker 控制器 (See here)
图像选择器控制器返回 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。虽然发生这种情况时,我得到一个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.
当我将targetSize设置为CGSize(width: 100, height: 100)时不会出现错误
【问题讨论】: