SwiftUI Chapter 12 Gestures

It appears that in Swift UI when there are two gestures added to a view, only the first one is implemented. In the CardView.swift body if I create gestures in this order

    .gesture(TapGesture()
        .onEnded {
            withAnimation(.easeIn, {
                self.revealed = !self.revealed
            })
        })
    .gesture(longPress)

The tap gesture works but not the Long Press. On the other hand, a simple swap

    .gesture(longPress)
    .gesture(TapGesture()
        .onEnded {
            withAnimation(.easeIn, {
                self.revealed = !self.revealed
            })
        })

and the long press is enabled and the tap ignored.

Is this a SwiftUI bug, or is there a work-around/fix?

Thanks

Thereโ€™s an Apple article that gives some more info the complexity of combining gestures. Apple Developer Documentation

1 Like