'requestImageData was deprecated in iOS 13
I am getting this depreciation message in my my project:
requestImageData(for:options:resultHandler:)was deprecated in iOS 13
What is the most updated method to fix this?
func convertImageFromAsset(asset: PHAsset) -> UIImage? {
var img: UIImage?
let manager = PHImageManager.default()
let options = PHImageRequestOptions()
options.version = .original
options.isSynchronous = true
manager.requestImageData(for: asset, options: options) { data, _, _, _ in
if let data = data {
img = UIImage(data: data)
}
}
return img
}
Solution 1:[1]
As it says in the documentation, you should use requestImageDataAndOrientation - it has the same API, I think this is just a renaming done for better readability.
manager.requestImageDataAndOrientation(for: asset, options: options) { data, _, _, _ in
if let data = data {
img = UIImage(data: data)
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Pylyp Dukhov |
