Cannot assign value of '[PHAsset]' to type 'UIImageView!'
I'm having an issue here:
UPDATED QUESTION
// CONVERT PHASSET TO UIIMAGE
func getAsset(asset: PHAsset) -> UIImage {
let manager = PHImageManager.defaultManager()
let option = PHImageRequestOptions()
var image = UIImage()
option.synchronous = true
manager.requestImageForAsset(asset, targetSize: CGSize(width: 100.0, height: 100.0), contentMode: .AspectFit, options: option, resultHandler: {(result, info)->Void in
image = result!
})
return image
}
func doneButtonDidPress(images: [UIImage]) {
self.imagePickerController.dismissViewControllerAnimated(true, completion: nil)
var selectedImg = imagePickerController.stack.assets
getAsset(selectedImg)
self.SelectImageView.image = UIImage(named: chosenImg)
}
But yet i get errors as shown in the image below
The variable selectedImage is of type PHAsset
The variables self.backgroundImageView and self.SelectImageView are of type UIImageView
These two types do not match, so Swift will not allow you to make the assignments.
To make the assignment, you will have to convert PHAsset to UIImage and then assign this UIImage to the UIImageView
[PHAsset]
is an array of PHAsset
objects. To get an image from the array, get the PHAsset
from the specific index you want and use requestImageForAsset:targetSize:contentMode:options:resultHandler:
to get the image from the asset.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.