1

I am trying to create an app that takes more than a single photo. What I want is every time​ I take a photo I want the camera opens right after the first photo.

import UIKit

class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

    @IBOutlet var myImage: UIImageView!

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    @IBAction func takePhoto(_ sender: Any) {
        if UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.camera) {
            let imagePicker = UIImagePickerController()
            imagePicker.delegate = self
            imagePicker.sourceType = UIImagePickerController.SourceType.camera
            imagePicker.allowsEditing = false
            self.present(imagePicker, animated: true, completion: nil)
        }
    }

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        if let pickedImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
            myImage.contentMode = .scaleToFill
            myImage.image = pickedImage
        }
        picker.dismiss(animated: true, completion: nil)
    }

}
manishsharma93
  • 1,039
  • 1
  • 11
  • 26
HasanChute
  • 61
  • 1
  • 2
  • Dont use UIImagePicker, use AVFoundation instead. see [here](https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/avcam_building_a_camera_app) and [here](https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/capturing_still_and_live_photos) – Scriptable Aug 01 '19 at 14:04
  • 1
    Could you explain what you are trying to do more clearly? – Alan S Aug 01 '19 at 14:12
  • UIImagePicker doesn't provide an option of picking multiple photos. Try 3rd party like YPImagePicker – Ashish Aug 01 '19 at 14:14

0 Answers0