LAST CHANCE: Save 50% on all my Swift books and bundles! >>

How can I use a ScrollView with a swipe gesture?

Forums > SwiftUI

Hi, this is my code:

struct SolverFullScreenCover: View {
    @Environment(\.presentationMode) var presentationMode
    var systemSolver: SystemSolver

    var body: some View {
        ScrollView {
            fullScreenHeader(systemSolver: systemSolver)  // This is a view from another file
        }
        .ignoresSafeArea()
        .onSwipeDown(){
            presentationMode.wrappedValue.dismiss()
        }
    }
}

The gesture works, but the ScrollView can't scroll. Thanks for the help in advance!

   

Also, I have another problem: The dismiss Button doesn't work when I try to use ForEach.

struct ChooserRow: View {
    @State private var isShown = false

  let columns = [
      GridItem(.adaptive(minimum: 280 , maximum: 1000), spacing: 30)
  ]

  var systemSolvers: [SystemSolver]

  var body: some View {
      ScrollView {
          LazyVGrid(columns: columns, alignment: .center) {

              ForEach(systemSolvers) { solver in
                  ChooserButton(systemSolver: solver, frame: [350, 350])
                      .padding(.vertical)

              }
          }
      }
  }
}

struct ChooserRow_Previews: PreviewProvider {
  static var previews: some View {
      ChooserRow(systemSolvers: ModelData().systemSolvers)
  }
}

   

Click here to save 50% on all my books and bundles!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.