我正在使用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
}
}
}
答案 0 :(得分:1)
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(具有:150,高度:150),除非由于内存不足而要爆炸设备。
答案 1 :(得分:-1)
PHImageRequestOptions *option = [[PHImageRequestOptions alloc] init];
option.synchronous = YES;
``
将synchronous 属性设置为YES