Created
October 12, 2018 08:09
-
-
Save rajajawahar/b78d3166e0a75c5663cfbe8233c294de to your computer and use it in GitHub Desktop.
This file contains 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
import UIKit | |
class ViewController: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate { | |
let imagePicker = UIImagePickerController() | |
@IBOutlet weak var browsedImageView: UIImageView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
imagePicker.delegate = self | |
imagePicker.allowsEditing = true | |
imagePicker.sourceType = .camera | |
} | |
@IBAction func browseCamera(_ sender: UIBarButtonItem) { | |
present(imagePicker, animated: true, completion: nil) | |
} | |
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { | |
let userpickedImage = info[UIImagePickerController.InfoKey.originalImage] | |
browsedImageView.image = userpickedImage as? UIImage | |
imagePicker.dismiss(animated: true, completion: nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment