Created
August 4, 2017 06:27
-
-
Save NikhilManapure/ce2aecb9a53ea871043f9df76cfa7169 to your computer and use it in GitHub Desktop.
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
| extension ViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { | |
| func presentImagePicker(allowingEditing: Bool) { | |
| if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.photoLibrary){ | |
| let imagePickerController = UIImagePickerController() | |
| imagePickerController.delegate = self | |
| imagePickerController.sourceType = UIImagePickerControllerSourceType.photoLibrary; | |
| imagePickerController.allowsEditing = allowingEditing | |
| self.present(imagePickerController, animated: true, completion: nil) | |
| } | |
| } | |
| func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info:[String : Any]) { | |
| if info.keys.contains(UIImagePickerControllerEditedImage) { | |
| var image = info[UIImagePickerControllerEditedImage] as? UIImage | |
| } else { | |
| var image = info[UIImagePickerControllerOriginalImage] as? UIImage | |
| } | |
| update(with: image) | |
| self.dismiss(animated: true, completion: nil) | |
| } | |
| func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { | |
| self.dismiss(animated: true, completion: nil) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment