gpt4 book ai didi

ios - 将 PHAsset 转换为 UIImage 时出现非致命但意外的错误

转载 作者:搜寻专家 更新时间:2023-10-30 22:29:21 26 4
gpt4 key购买 nike

我正在使用此代码将 PHAsset 转换为全尺寸 UIImage:

func getOriginalAsset(asset: PHAsset, onComplete: @escaping (UIImage?, [AnyHashable: Any]?) -> ()) {
let manager = PHImageManager.default()
let option = PHImageRequestOptions()
option.isNetworkAccessAllowed = true

manager.requestImage(for: asset, targetSize: PHImageManagerMaximumSize, contentMode: .aspectFit, options: option) { (image, info) in
onComplete(image, info)
}
}

但是,每次我尝试运行此代码时,我都会从控制台收到此警告:

[ImageManager] First stage of an opportunistic image request returned a non-table format image, this is not fatal, but it is unexpected

问题

  1. 为什么我会收到此警告?

  2. 我该如何解决?

更新

尽管有警告,当我运行这段代码时一切正常。我无法忍受我的应用程序中的任何警告/错误(也许我迟早要学会接受它)

最佳答案

尝试使用这段代码,我添加isSynchronous = true 你可以阅读这份文件isSynchronous

I will explain to you the problem the cause the problem quickly 出现这个问题是因为opatation一直显示到图像的末尾并且你请求大尺寸图像可能需要时间所以你应该在Thread等待期间直到处理获取图像

func getOriginalAsset(asset: PHAsset, onComplete: @escaping (UIImage?, [AnyHashable: Any]?) -> ()) {
let manager = PHImageManager.default()
let option = PHImageRequestOptions()
option.isNetworkAccessAllowed = true
option.isSynchronous = true
manager.requestImage(for: asset, targetSize: PHImageManagerMaximumSize, contentMode: .aspectFit, options: option) { (image, info) in
onComplete(image, info)
}
}

关于ios - 将 PHAsset 转换为 UIImage 时出现非致命但意外的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49865609/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com