Created
September 24, 2015 20:15
-
-
Save andrebian/73321f80f0e9371c8c6b to your computer and use it in GitHub Desktop.
Revisions
-
andrebian created this gist
Sep 24, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ import UIKit import MobileCoreServices class ViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate { @IBOutlet weak var imgView: UIImageView! var newMedia: Bool? override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBAction func takePicture(sender: AnyObject) { if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) { let picker = UIImagePickerController() picker.delegate = self picker.sourceType = UIImagePickerControllerSourceType.Camera picker.mediaTypes = [kUTTypeImage as String] picker.allowsEditing = false self.presentViewController(picker, animated: true, completion: nil) } else { NSLog("No Camera.") let alert = UIAlertController(title: "No camera", message: "Please allow this app the use of your camera in settings or buy a device that has a camera.", preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default, handler: nil)) self.presentViewController(alert, animated: true, completion: nil) } } func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: NSDictionary, editingInfo: [String : AnyObject]?) { let temp: UIImage = info[UIImagePickerControllerOriginalImage] as! UIImage print("Exibindo a imagem tirada") print(temp) imgView.image = temp self.dismissViewControllerAnimated(true, completion: nil) } }