В resultHandler
вы должны использовать (image, _)
вместо (result:UIImage!, info:NSDictionary!)
func displayPhoto() {
let imageManager = PHImageManager.default()
var ID = imageManager.requestImage(
for: self.photosAsset[self.index] as PHAsset,
targetSize: PHImageManagerMaximumSize,
contentMode: .aspectFit,
options: nil,
resultHandler: { (image, _) in
self.imgView.image = image
}
)
}
Примечание: Для улучшения вашего метода вы можете установить PHImageRequestOptions
в options:
func displayPhoto() {
let imageManager = PHImageManager.default()
let requestOption = PHImageRequestOptions()
requestOption.isSynchronous = true
requestOption.deliveryMode = .highQualityFormat
var ID = imageManager.requestImage(
for: self.photosAsset[self.index] as PHAsset,
targetSize: PHImageManagerMaximumSize,
contentMode: .aspectFit,
options: requestOption,
resultHandler: { (image, _) in
self.imgView.image = image
}
)
}