我正在尝试从相机或图库中选择图像,并在我的 ImageView 中将所选图像显示到屏幕上。但它没有显示。
func imagePickerController(_ picker: UIImagePickerController,
didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
guard let selectedImage = info[.originalImage] as? UIImage else {
fatalError("Expected a dictionary containing an image, but was provided the following: \(info)")
}
imageview.image = selectedImage
dismiss(animated: true, completion: nil)
}
我错过了什么?
在我的例子中,断点函数根本没有被调用
最佳答案
如果您的断点函数不在调用时,那么我认为您还没有在 viewDidLoad() 中设置 imagePicker 委托(delegate)
override func viewDidLoad() {
super.viewDidLoad()
imagePicker.delegate = self
}
关于ios - 从图库或相机中选择图像后 UIImage 未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54157346/