title: swift 3 Application tried to present modally an active controller camera
body: <p>I am able to tap a button and pull up the camera roll and select an image and have it fill an empty imageView.</p>
  
  <p>Next I tried to add a button that lets the user use the camera.</p>
  
  <p>I was following a tutorial and I have the security rules set up for both option. However I still get a crash that says </p>
  
  <blockquote>
    <p>Application tried to present modally an active controller</p>
  </blockquote>
  
  <p>I searched SO and found answers suggesting that I replace my line </p>
  
  <pre><code>present(picker,animated: true,completion: nil)
  </code></pre>
  
  <p>with </p>
  
  <pre><code>self.navigationController?.pushViewController(picker, animated: true)
  </code></pre>
  
  <p>However this just causes another error.</p>
  
  <p>This is my full code for pulling the camera</p>
  
  <pre><code>picker.allowsEditing = true
  picker.sourceType = UIImagePickerControllerSourceType.camera
  picker.cameraCaptureMode = .photo
  picker.modalPresentationStyle = .fullScreen
  present(picker,animated: true,completion: nil)
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>my code now looks like this</p>
  
  <pre><code>func useCamera() {
    let picker = UIImagePickerController()
    picker.delegate = self
    picker.allowsEditing = false
    picker.sourceType = .camera
    present(picker, animated: true, completion: nil)
  }
  </code></pre>
  
  <p>and I have also tried this</p>
  
  <pre><code>    func useCamera() {
        if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {
          let picker = UIImagePickerController()
          picker.delegate = self
          picker.allowsEditing = false
          picker.sourceType = .camera
          present(picker, animated: true, completion: nil)
      }
    }
  </code></pre>
  
  <p>but what happens now is that it just opens up the camera roll and in the console I see this </p>
  
  <blockquote>
    <p>Attempt to present UIImagePickerController: 0x1018c4000 on
    Lended.AddAccountViewController: 0x10116f540 whose view is not in the
    window hierarchy!</p>
  </blockquote>
  
  <p>but the app does not crash, which is good</p>