简体   繁体   English

带有拖动手势的单元格使用 SwiftUI 覆盖列表滚动

[英]Cells with drag gesture overwrite the list scrolling using SwiftUI

I have a SwiftUI List with cells that are able to recognize drag gestures in order to swipe them.我有一个 SwiftUI 列表,其中包含能够识别拖动手势以便滑动它们的单元格。

The problem is that the drag gesture overlaps the scroll recognition of the list, so I only can swipe the cells.问题是拖动手势与列表的滚动识别重叠,所以我只能滑动单元格。 I can not scroll the list.我无法滚动列表。

Is there a way in SwiftUI to tell the List that have to handle multiple gestures? SwiftUI 中有没有办法告诉 List 必须处理多个手势?

You can set minimumDistance to some value (for instance 30) on your cell item.您可以在单元格项minimumDistance设置为某个值(例如 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))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM