Swift - ImagePicker not executing delegate
<p>I just want to display an image taken with the iPhone camera in a <code>ImageView</code>. That was the first step of the project but it doesn't work...</p>

<p><strong>Here is my code :</strong></p>

<pre><code>import UIKit
import MobileCoreServices

class ViewController: UIViewController,UIImagePickerControllerDelegate, UINavigationControllerDelegate {

    @IBOutlet weak var imageView: UIImageView!
    @IBOutlet weak var scanButton: UIButton!
    @IBOutlet weak var textfield: UITextField!

     let imagePicker = UIImagePickerController()


    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        self.imagePicker.modalPresentationStyle = UIModalPresentationStyle.currentContext
        self.imagePicker.delegate = self
        self.imagePicker.mediaTypes = [kUTTypeImage as String]
        self.imagePicker.sourceType = .camera
        self.imagePicker.allowsEditing = true;


    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    //MARK: - Actions

    @IBAction func scanAction(_ sender: UIButton) {

        print("----- scanAction -----");

        self.present(self.imagePicker, animated: true, completion: nil)
    }


    //MARK: - UIImagePickerControllerDelegate

    private func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {

        print("----- didFinishPickingMediaWithInfo -----");

        var image:UIImage!;
        if let  pickedImage = info[UIImagePickerControllerEditedImage] as? UIImage {
            image = pickedImage;
        }
        else {
            image = info[UIImagePickerControllerOriginalImage] as! UIImage;
        }

        self.imageView.image = image;


        dismiss(animated: true, completion: nil)
    }

    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        print("----- imagePickerControllerDidCancel -----");

        dismiss(animated: true, completion: nil)
    }

}
</code></pre>

<p>I see the print of the action button but I never see the following one :</p>

<pre><code>print("----- didFinishPickingMediaWithInfo -----");
</code></pre>

<p>I already have done <code>imagePicker</code> like this in the past so I don't understand why it doesn't work.</p>

<p>Can someone help me please?</p>