简体   繁体   中英

Single tap doesn't work in combination with double tap

To image, I have attached several gestures and all but single tap worked as expected.

Below is the image along with gestures attached to it:

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
                            }))

Does anyone know what might be wrong and how to enable single tap gesture along wit other gestures?

Thank you.

It is consumed by DragGesture(minimumDistance: 0... , so the solution either to make drag really drag at least by some

DragGesture(minimumDistance: 1...

or make single tap simultaneous

.simultaneousGesture(TapGesture(count: 1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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