为了进行图像显示,我附加了几个手势,除单击外,所有手势均按预期工作。
下面是图像以及附加的手势:
Image(uiImage: UIImage(named: "shatan_tree.png")!)
.gesture(TapGesture(count: 2)
.onEnded({
// this code is executed as expected
}).simultaneously(with: DragGesture(minimumDistance: 0, coordinateSpace: .global).onChanged({
// this code is executed as expected
})
.onEnded({ (value) in
// this code is executed as expected
})))
.gesture(TapGesture(count: 1)
.onEnded({
// this doesn't work
print("single tap")
}))
.gesture(MagnificationGesture()
.onChanged({ (scale) in
// this code is executed as expected
})
.onEnded({ (scaleFinal) in
// this code is executed as expected
}))
有谁知道这可能是什么问题,以及如何与其他手势一起启用单击手势?谢谢。
最佳答案
它由DragGesture(minimumDistance: 0...
消耗,因此解决方案要么使拖动真正至少拖动一些DragGesture(minimumDistance: 1...
或同时单击.simultaneousGesture(TapGesture(count: 1)
关于ios - 单按不能与双按组合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63100667/