I am Swift beginner and just completed my Photo camera function in my app. The problem which I have now is that when I take a photo from the camera, it is not saved into the photo library on my iPhone. Everything works perfectly I am able to take pictures, but when I check in Photos, it seems that they are not saved. I had checked for similar questions, but I haven't found a proper answer, I see that they are people who add buttons to access the photo library directly but I do not need such a button. The only function, I require is taking a picture and when the user clicks select photo to save it in the Photos.
So far I have used this:
class ViewController: UIViewController, UIImagePickerControllerDelegate,UINavigationControllerDelegate{
let imagePicker: UIImagePickerController! = UIImagePickerController()
override func viewDidLoad() {
super.viewDidLoad()
imagePicker.delegate = self
let upSwipe = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipes))
upSwipe.direction = .up
view.addGestureRecognizer(upSwipe)
}
and the function:
func handleSwipes(sender:UISwipeGestureRecognizer) {
if (sender.direction == .up){
if ( UIImagePickerController.isSourceTypeAvailable(.camera)){
if UIImagePickerController.availableCaptureModes(for: .rear) != nil {
imagePicker.allowsEditing = false
imagePicker.sourceType = .camera
imagePicker.cameraCaptureMode = .photo
present(imagePicker,animated: true, completion: {})
}
}
Here is what I get on my iPhone: I only want when the user chooses to use the photo, the photo itself to be saved in the gallery, as simple as that.