title: How to take picture automatically by programming in Swift?
body: <p>I am developing in Swift with iPhone camera.</p>
  
  <p>I using the following code to check the camera:</p>
  
  <pre><code>if UIImagePickerController.isSourceTypeAvailable(.Camera) {   
      let picker = UIImagePickerController()
          picker.delegate = self
          picker.sourceType = UIImagePickerControllerSourceType.Camera
          picker.allowsEditing = true  
          self.presentViewController(picker, animated: true)
      } else {
          print("can't find camera")
      }
  }
  </code></pre>
  
  <p>And I use the following code to open the camera.</p>
  
  <pre><code>presentViewController(imagePicker, animated: true, completion: nil)
  </code></pre>
  
  <p>I have reference the following <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImagePickerController_Class/#//apple_ref/occ/instm/UIImagePickerController/takePicture" rel="nofollow noreferrer">link</a> and call <code>takePicture()</code> , but it seems did not working.</p>
  
  <p>But I always need to manually take the picture by tapping the shutter button. Is programmatically taking the picture possible in Swift?</p>
  
  <p>Thanks in advance.</p>