ios - 单按不能与双按组合使用

标签 ios swift swiftui

为了进行图像显示,我附加了几个手势,除单击外,所有手势均按预期工作。
下面是图像以及附加的手势:

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/

相关文章:

ios - WKWebViewJavascriptBridge 的 Xcode 链接器错误

ios - 简单的 stringByReplacingOccurrencesOfString 帮助问题

ios - 尝试创建具有预定义图像的结构实例。不确定结构或实例代码是否关闭

ios - 在 AFNetwoking 3.0 中上传 Zip 文件

ios - Swift - 发送到实例的无法识别的选择器

ios - 无法在 Swift 中获取 UITextField 的 .text 属性——错误 : "Instance member ' textFieldName' cannot be used on type 'ViewController'

ios - 将文件加载到应用程序本地存储

swift - 如何在SwiftUI中制作刮刮卡效果?

swift - 如何在 SwiftUI 中修改列表的背景颜色?

SwiftUI - 半模态?