[ad_1]
When loading pictures from the picture library by way of PhotoKit, it could actually occur that the picture just isn’t downloaded from iCloud. On this case, a low-resolution “placeholder” model of that picture is offered domestically if you happen to browse it within the photographs App:
Nonetheless, when I attempt to get the identical picture to show in an app, the picture that I get from PHAssetManager shall be at most 120 items extensive (or excessive). This appears to be like very blurry and is totally unusable apart from a thumbnail.
I’ve already tried
PHImageManagerMaximumSizebecause the goal dimensionresizeMode = .noneand.actual- all of the
deliveryMode‘s requestImageDataAndOrientation- to learn the picture information another way, e.g. by
privateFileURLproperty on the asset
I wished to ask if anybody has come throughout this concern and possibly labored round it.
The habits could be simply reproduced with some PhotoKit instance app, for instance from these course supplies.
That is the code I used to provide the under picture:
extension UIImageView {
func fetchImageAsset(_ asset: PHAsset?, targetSize dimension: CGSize, contentMode: PHImageContentMode = .aspectFill, completionHandler: ((Bool) -> Void)?) {
let choices = PHImageRequestOptions()
choices.deliveryMode = .opportunistic
choices.resizeMode = .none
choices.isNetworkAccessAllowed = false
// 1
guard let asset = asset else {
completionHandler?(false)
return
}
// 2
let resultHandler: (UIImage?, [AnyHashable: Any]?) -> Void = { picture, data in
if let picture = picture {
self.picture = picture
}
completionHandler?(true)
}
// 3
PHImageManager.default().requestImage(
for: asset,
targetSize: dimension,
contentMode: contentMode,
choices: choices,
resultHandler: resultHandler)
}
}
[ad_2]


