I have simple scenario in my app.
I have 1 edit UIButton
to select image from Photo Library and show that selected image in UIImageView
.
@IBAction func btnEdit(_ sender: UIButton) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.photoLibrary) {
let picker:UIImagePickerController = UIImagePickerController()
picker.sourceType = .photoLibrary
picker.delegate = self
picker.allowsEditing = true
picker.sourceType = .photoLibrary
picker.navigationBar.isTranslucent = false
self.present(picker, animated: true)
} else {
print("Photo Library is not available.")
}
}
UINavigationControllerDelegate & UIImagePickerControllerDelegate
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let pickedimage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage {
self.imageView.image = pickedimage
} else if let pickedimage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
self.imageView.image = pickedimage
} else {
print("Something went wrong while select photo from Library...!")
}
dismiss(animated: true, completion: nil)
}
Its working well. But selected image is saving automatically in tmp folder
I don't want to save in Document directory.
How to stop automatically saving images in Document directory?