SwiftUI View gesture prevents seperate UIViewController touch events

I have a UIViewRepresentable inside my ContentView as well as other SwiftUI views.


When the UIViewRepresentable is touched or any SwiftUI view is receiving a gesture independently, the views respond as expected.


While I am touching the UIViewRepresentable, I can still still adjust the SwiftUI views (they still accept gestures).


HOWEVER, while I am doing a gesture on a SwiftUI, I cannot receive touch events on my UIViewRepresentable. I need to be able to do this.


There is no overlap between any of the views (they are not graphically blocking each other).


I can adjust multiple SwiftUI views at the same time, why can't I also adjust a UIViewRepresentable at the same time?


My UIViewRepresentable is a musical keyboard. My SwiftUI views adjust the sound played. I need to be able to interact with both at the same time regardless of which was pressed first.

I have similar problem: my UIView's gestures convict with SwiftUI view's gestures. They trigger simultaneously :(
You might need to create a custom UIGestureRecognizer if you don't already have one in your UIViewRepresentable, but if you do, just add the following method to it:

Code Block swift
override func canBePrevented(by preventingGestureRecognizer: UIGestureRecognizer) -> Bool {
    false
}


I am also having the same problem. It happens with the drag gestures in swiftui. When a swiftui view is touched for drag, the new touchesBegan, will not work anymore on UIViewRepresentable. Please provide a solution, else I have to go back to UIKit, dropping swiftUI.

SwiftUI View gesture prevents seperate UIViewController touch events
 
 
Q