PHImageManager 抛出 "First stage of an opportunistic image request returned a non-table format image, this is not fatal, but it is unexpected"

PHImageManager throws "First stage of an opportunistic image request returned a non-table format image, this is not fatal, but it is unexpected"

我正在使用 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) 除非你想因为内存耗尽而爆炸你的设备。

PHImageRequestOptions *option = [[PHImageRequestOptions alloc] init];
option.synchronous = YES;
``
将synchronous 属性设置为YES