I want to know how I can save images I get from the bilbotrop of photos on the coredata.
I have an imageView that when touching it I can choose a photo from the library my problem is when I close the app and reopen the image is not there.
How can I save the image and when the app reopens the image continues in the imageview
Is coredata the best option for this?
class V1Menino: UIViewController, UITextFieldDelegate, GADBannerViewDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate,UIScrollViewDelegate {
@IBOutlet weak var sViewV1: UIScrollView!
@IBOutlet weak var imageV1: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
self.view.layoutIfNeeded()
self.sViewV1.minimumZoomScale = 1.0
self.sViewV1.maximumZoomScale = 6.0
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped(tapGestureRecognizer:)))
imageV1.isUserInteractionEnabled = true
imageV1.addGestureRecognizer(tapGestureRecognizer)
}
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return self.imageV1
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: Any]){
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage
{
imageV1.image = image
}
self.dismiss(animated: true, completion: nil)
}
@objc func imageTapped(tapGestureRecognizer: UITapGestureRecognizer)
{
//let tappedImage = tapGestureRecognizer.view as! UIImageView
// sua acao
let image = UIImagePickerController()
image.delegate = self
image.sourceType = UIImagePickerControllerSourceType.photoLibrary
self.present(image,animated: true)
{
//depois disso ta completo
}
}
}