UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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!

3      

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)
  }
}

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.