简体   繁体   English

UIImagePickerController不将图像保存到UIImageView

[英]UIImagePickerController not saving image to UIImageView

So I have looked around and tried a few different things and I still can't seem to figure out why the image is not being saved to the UIImageView. 因此,我环顾四周并尝试了一些不同的尝试,但我似乎仍然无法弄清楚为什么未将图像保存到UIImageView。 I have checked and the View Controller conforms to all protocols as necessary and I have set the Image Picker delegate to self. 我已经检查过,并且View Controller根据需要遵守所有协议,并且将Image Picker委托设置为self。 here is the code for handling the image that is chosen. 这是用于处理所选图像的代码。 Everything else works just no image is sent to the Image View after it is selected. 其他所有工作都正常,只是在选择图像后没有图像发送到图像视图。

 func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
recipeImage.image = info[UIImagePickerControllerOriginalImage] as? UIImage
picker.dismissViewControllerAnimated(true, completion: nil)
}

Try dismissing imagePicker first like this 尝试像这样先关闭imagePicker

 func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) 
{
picker.dismissViewControllerAnimated(true, completion: nil)
recipeImage.image = info[UIImagePickerControllerOriginalImage] as? UIImage

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM