I am using this code to convert a PHAsset
to a full size 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)
}
}
However, I'm getting this warning from the console every time I try to run this code:
[ImageManager] First stage of an opportunistic image request returned a non-table format image, this is not fatal, but it is unexpected
Question
Why do I get this warning?
How do I resolve this?
Update
Everything works fine when I run this code despite the warning. I just can't stand any warnings/errors in my app (Maybe I'll have to learn to accept it sooner or later)
try use this code , I'm add isSynchronous = true
you can read this document isSynchronous
I will explain to you the cause of the problem quickly This problem occurs because the opatation is shown until the end of the image and you request large size images may take time so you should be Thread in the waiting period until the process of fetching the image
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)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With