我想知道如何將圖像保存在coredata上的照片上。如何在覈心數據上保存圖像SWIFT
我有一個imageView,當它觸摸它時,我可以從庫中選擇一張照片我的問題是當我關閉應用程序並重新打開圖像不存在。
我如何保存圖像和當應用程序重新打開圖像繼續在imageview的
是coredata這是最好的選擇?
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
}
}
}
你對我怎麼能做到這一點的任何教程,或任何文件,我可以更好地閱讀理解? –