Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

.highPriorityGesture Prevents Button Tap on iOS 17 and Earlier

In iOS 18, using .highPriorityGesture does not interfere with Button tap detection. However, on iOS 17 and earlier, setting a .highPriorityGesture causes the Button's tap action to stop responding.

I am using .highPriorityGesture in an attempt to support both tap and long-press gestures on a Button, which works as expected in iOS 18. However, the same implementation prevents taps on earlier versions.

Is using .highPriorityGesture on a Button not recommended in this case? Or is this an issue specific to how .highPriorityGesture behaves on iOS 17 and earlier?

Below is a sample code:

struct SampleButton: View {
    let title: String
    let action: () -> Void
    
    var body: some View {
        Button {
            NSLog("Tapped")
            action()
        } label: {
            Text(title)
        }.highPriorityGesture(LongPressGesture(minimumDuration: 0.5).onEnded { _ in
            NSLog("Long press.")
            action()
        })
    }
}

struct ContentView: View {
    var body: some View {
        VStack {
            SampleButton(title: "Tap or LongPress") {}
        }
    }
}

Environment:

  • Xcode: Version 16.3 (16E140)
  • iOS: iOS 18.4(simulator), iOS 17.5, iOS 16.4, iOS 15.2

Are you trying to give a gesture precedence over the view’s existing gesture or are you trying to process a specific gesture simultaneously with the same priority as the view’s existing gestures ?

These are two different behaviors, if you're intending for the latter use simultaneousGesture(_:including:) instead.

Is using .highPriorityGesture on a Button not recommended in this case? Or is this an issue specific to how .highPriorityGesture behaves on iOS 17 and earlier?

The behavior on iOS 18 seems appropriate, however if you'd like engineering to investigate the issue, you could open a bug report, include a test project and post the FB number here once you do. Bug Reporting: How and Why? has tips on creating your bug report.

Thank you for the reply.

Our product previously used simultaneousGesture(_:including:). Recently, I discovered highPriorityGesture and tried using it. It works as expected on iOS 18, but on iOS 17.5 and earlier, the Button tap does not respond, which is why I posted this question.

Although there is a difference in behavior between iOS 18 and earlier versions, I would like to use highPriorityGesture to implement our feature specifically for iOS 18.

The behavior on iOS 18 seems appropriate, however if you'd like engineering to investigate the issue, you could open a bug report, include a test project and post the FB number here once you do. Bug Reporting: How and Why? has tips on creating your bug report.

I have posted FB17598905

.highPriorityGesture Prevents Button Tap on iOS 17 and Earlier
 
 
Q