gpt4 book ai didi

ios - UIImageView 不会显示从 UIImagePicker 中选择的图像

转载 作者:行者123 更新时间:2023-11-28 13:55:14 25 4
gpt4 key购买 nike

我的 imageView 不显示我用 UIImagePicker 选择的图片。

这是它的所有代码:

@IBAction func addImage(_ sender: Any) {
if !didShowCamera {
imagePicker = UIImagePickerController()
imagePicker.delegate = self

if UIImagePickerController.isSourceTypeAvailable(.camera) {
imagePicker.sourceType = .camera
imagePicker.cameraCaptureMode = .photo
} else {
imagePicker.sourceType = .photoLibrary
}

self.present(imagePicker, animated: true, completion: nil)
}
}

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let image = info[UIImagePickerController.InfoKey.originalImage] as! UIImage
print(image)
self.jobImage.image = takenImage
self.takenImage = image
didShowCamera = true
self.dismiss(animated: true, completion: nil)
}

有什么解决办法吗?

最佳答案

使用调度主队列

DispatchQueue.main.async {
self.jobImage.image = takenImage
self.takenImage = image
}

关于ios - UIImageView 不会显示从 UIImagePicker 中选择的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53970790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com