title: iOS 11 - always opens photo library even the source type change it from .photoLibrary to .camera
body: <p>The code is perfectly working in iOS 10 and below. But, in iOS 11 after  cancel the photo library and open the camera its always opens the photo library. This is only happening in iOS 11.</p>
  
  <p>Code is compiled in <strong>Xcode 9 Beta 4</strong>.</p>
  
  <p><strong>Code below:</strong></p>
  
  <pre><code>@IBAction func buttonProfilePicPressed(_ sender: UIButton)
  {
      let alert = UIAlertController(title: "Choose Image", message: nil, preferredStyle: .actionSheet)
      alert.addAction(UIAlertAction(title: "Camera", style: .default, handler: { _ in
          self.openCamera()
      }))
  
      alert.addAction(UIAlertAction(title: "Gallery", style: .default, handler: { _ in
          self.openGallary()
      }))
  
      alert.addAction(UIAlertAction.init(title: "Cancel", style: .cancel, handler: nil))
  
      self.present(alert, animated: true, completion: nil)
      imgPicker.delegate = self
      self.present(imgPicker, animated: true, completion: nil)
  }
  
  func openCamera()
  {
      if(UIImagePickerController .isSourceTypeAvailable(UIImagePickerControllerSourceType.camera))
      {
          imgPicker.sourceType = UIImagePickerControllerSourceType.camera
          imgPicker.allowsEditing = true
          self.present(imgPicker, animated: true, completion: nil)
      }
      else
      {
          let alert  = UIAlertController(title: "Warning", message: "You don't have camera", preferredStyle: .alert)
          alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
          self.present(alert, animated: true, completion: nil)
      }
  }
  
  func openGallary()
  {
      imgPicker.sourceType = UIImagePickerControllerSourceType.photoLibrary
      imgPicker.allowsEditing = true
      self.present(imgPicker, animated: true, completion: nil)
  }
  </code></pre>