didFinishPickingMediaWithInfo not called

1. Dont forget to add UIImagePickerControllerDelegate,UINavigationControllerDelegate
2. In your viewDidLoad() add picker.delegate = self
3. Add the delegate methods

public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage 
        userImageView.contentMode = .scaleAspectFit
        userImageView.image = chosenImage
        dismiss(animated:true, completion: nil)
    }

public func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {self.dismiss(animated: true, completion: nil)
}

Hope it helps :)


In Swift 3, this delegate method is now called:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])

The differences are:

  1. There is an underline _ before picker
  2. info type at the end is changed from [String : AnyObject] to [String : Any]

I had the same issue and when I made these changes it worked.