Reputation:
I want to add two gesture recongnisers to a view, but I'm unsure how to do it! I've tried the below, but only the first one fires (whatever order they are in).
.gesture(
TapGesture(count: 2)
.onEnded { _ in
print("Double Tap!")
}
)
.gesture(
LongPressGesture()
.onEnded { _ in
print("Long Press!")
}
)
I thing I need to use simultaneousGesture, but I'm unsure of the syntax. I've tried:
.simultaneousGesture(LongPressGesture().onEnded({self.showAddEditToDoView.toggle()}), TapGesture().onEnded({print("Double Tap!")}))
But that produces:
Missing argument label 'including:' in call
Any help much appreciated.
Upvotes: 5
Views: 4757
Reputation: 7636
try
.simultaneousGesture(LongPressGesture().onEnded({ _ in
self.showAddEditToDoView.toggle()
}))
.simultaneousGesture(TapGesture().onEnded({
print("Double Tap!")
}))
Upvotes: 8