title: Bug with image picker : When tapping on the album button the camera opens up
body: <p>I have two different buttons : Camera button and Album button. When tapping on the album button in order to select an image from photo library, the camera opens. Once I opened the camera by tapping in the camera button, the album works correctly.</p>
  <p>I don't know what to do. Here is my code :</p>
  <pre><code>struct MemeCreator: View {
      @State private var sourceType: UIImagePickerController.SourceType = .camera
      @State private var image: Image?
      @State private var showingImagePicker = false
      @State private var inputImage: UIImage?
      
      @Environment(\.presentationMode) var mode: Binding&lt;PresentationMode&gt;
      
      var body: some View {
          NavigationView {
              Group {
                  if let image = image {
                      Rectangle()
                          .scaledToFill()
                          .foregroundColor(.gray)
                          .overlay(
                              image
                                  .resizable()
                                  .scaledToFit()
                          )
                  }
              }
              .navigationBarTitle(Text(&quot;&quot;), displayMode: .inline)
              .toolbar {
                  ToolbarItemGroup(placement: .bottomBar) {
                      Button(
                          action: {
                              sourceType = .camera
                              showingImagePicker = true
                          }
                      ) {
                          Image(systemName: &quot;camera.fill&quot;)
                      }
                      
                      Button(
                          action: {
                              sourceType = .photoLibrary
                              showingImagePicker = true
                          }
                      ) {
                          Text(&quot;Album&quot;)
                      }
                  }
              }
          }
          .sheet(isPresented: $showingImagePicker, onDismiss: loadImage) {
              ImagePicker(image: $inputImage, sourceType: sourceType)
          }
      }
  </code></pre>
  <p>Here is the image picker's code :
  <a href="https://i.stack.imgur.com/oyEmM.png" rel="nofollow noreferrer">Image picker's script</a></p>