TransWikia.com

Single tap doesn't work in combination with double tap

Stack Overflow Asked by Niko Gamulin on November 28, 2020

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.

One Answer

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)

Correct answer by Asperi on November 28, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP