Last active
September 11, 2017 22:45
-
-
Save francoismarceau29/e74fd0f7c3d41312fba3c15f6726790a to your computer and use it in GitHub Desktop.
Creating an UIImagePickerController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func takePhotoTouched() { | |
let imagePicker = UIImagePickerController() | |
imagePicker.sourceType = .camera | |
imagePicker.delegate = self | |
imagePicker.allowsEditing = true | |
present(imagePicker, animated: true, completion: nil) | |
} | |
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { | |
dismiss(animated: true, completion: nil) | |
} | |
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { | |
dismiss(animated: true) { | |
if let image = info[UIImagePickerControllerEditedImage] as? UIImage { | |
let species = self.predict(image: image) | |
let alertController = UIAlertController(title: "Prediction", message: String(format: "The image is a %@", self.resultString(species: species)), preferredStyle: .alert) | |
let action = UIAlertAction(title: "Close", style: .default, handler: nil) | |
alertController.addAction(action) | |
self.navigationController?.present(alertController, animated: true, completion: nil) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment