ios - PHImageManager 抛出“机会性图像请求的第一阶段返回了非表格格式的图像,这不是致命的,但它是意外的”
问题描述
我正在使用 PHImageCachingManager 来获取 PHAsset 的图像。我需要使用该opportunistic
模式,以便首先加载可用的低分辨率图像,然后在全分辨率可用时加载。
出于某种原因,我不断收到以下警告,并且我的低分辨率图像无法加载。仅在获取最高分辨率(来自 iCloud)时才加载图像。
警告:
"First stage of an opportunistic image request returned a non-table format image, this is not fatal, but it is unexpected."
我究竟做错了什么?
let imageRequestOptions = PHImageRequestOptions()
imageRequestOptions.isNetworkAccessAllowed = true
imageRequestOptions.deliveryMode = .opportunistic
let imageCachingManager = PHCachingImageManager()
imageCachingManager.requestImage(for: asset , targetSize: PHImageManagerMaximumSize, contentMode: .aspectFill, options: imageRequestOptions) { (image, infoDict) in
DispatchQueue.main.async {
if self.myImageView.identifierTag == asset.localIdentifier {
self.myImageView.image = image
}
}
}
解决方案
imageCachingManager.requestImage(for: asset , targetSize: PHImageManagerMaximumSize, contentMode: .aspectFill, options: imageRequestOptions) { (image, infoDict) in
DispatchQueue.main.async {
if self.myImageView.identifierTag == asset.localIdentifier {
self.myImageView.image = image
}
}
}
您正在将可用的最大尺寸设置为图像尺寸。改变
targetSize: PHImageManagerMaximumSize
至
targetSize: CGSize(width: asset.pixelWidth, height: asset.pixelHeight)
或指定图像大小,如 CGSize(with: 150, height: 150) 除非您想因内存耗尽而爆炸设备。
推荐阅读
- r - 在 R 中使用矢量化创建新矩阵
- html - 活动步骤的步骤进度条
- reactjs - 子组件模式中的 useEffect
- elasticsearch - Kibana - 根据 Sum 聚合指标计算百分比
- firebase - ContentType 和元数据在存储写入规则中授予权限被拒绝
- interface - 如何将我的界面编码语言更改为英语
- android - 在 Android 11 上直接从内存访问文件
- python - 为什么我的 MatPlotLib 上的色标是向后的?
- python - 如果行中的项目满足列之间的条件,则附加到新的 df
- visual-studio-code - 在 vscode 片段中访问当前 git 分支