Advertisement
meganeura

Swift Take Photo

Sep 11th, 2014
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. //based on http://stackoverflow.com/a/24402451/1447641
  2. func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: NSDictionary!){
  3. println("i've got an image");
  4. self.mPhotoView.image = image
  5. picker.dismissViewControllerAnimated(true, completion: nil)
  6. }
  7.  
  8. @IBAction func takePhoto(sender: AnyObject) {
  9. if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
  10. println("Button capture")
  11.  
  12. var imag = UIImagePickerController()
  13. imag.delegate = self
  14. imag.sourceType = .Camera;
  15. imag.mediaTypes = NSArray(object: kUTTypeImage)
  16. imag.allowsEditing = false
  17.  
  18. self.presentViewController(imag, animated: true, completion: nil)
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement