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      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

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.