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

标签 ios swift uiimage phasset photosframework

我正在使用 PHImageCachingManager 获取 PHAsset 的图像。我需要使用机会主义模式,以便首先加载可用的低分辨率图像,然后在全分辨率可用时加载它。

出于某种原因,我不断收到以下警告,并且我的低分辨率图像无法加载。仅当(从 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),除非你想因为内存耗尽而爆炸你的设备。

关于ios - PHImageManager 抛出 "First stage of an opportunistic image request returned a non-table format image, this is not fatal, but it is unexpected",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55230259/

相关文章:

IOS + 德尔福 : low memory warnings - possible memory leak with TTexture?

objective-c - iOS App 中是否创建了很多自动释放池?

ios - 获取 UIPageViewController 的滚动位置

iOS7 - 如何给 UITextField 添加下划线

ios - 我如何在 React Native 中对相机执行平移?

ios - 无法在按钮上加载 UIImage

ios - 如何让 iOS 设备以编程方式播放音乐?

ios - 如何从 swift3 中的堆栈中删除除一个 View Controller 之外的所有 View Controller

ios - Swift:如何将通用协议(protocol)作为另一个协议(protocol)的参数传递

objective-c - 在 Swift 中从小图像生成纹理 UIImage