Adding a drag gesture in SwiftUI to a View inside a ScrollView blocks the scrolling

后端 未结 7 531
忘掉有多难
忘掉有多难 2020-12-23 12:49

So I have a ScrollView holding a set of views:

    ScrollView {
        ForEach(cities) { city in
            NavigationLink(destination: ...) {         


        
相关标签:
7条回答
  • 2020-12-23 13:52

    You can set minimumDistance to some value (for instance 30). Then the drag only works when you drag horizontally and reach the minimum distance, otherwise the scrollview or list gesture override the view gesture

    .gesture(DragGesture(minimumDistance: 30, coordinateSpace: .local)
    
    0 讨论(0)
提交回复
热议问题