ios – UIButton click on not working whether it is built-in in SwiftUI challenge


In SwiftUI I’ve a VStack with faucet gesture enabled. And this VStack Accommodates two buttons. One button is from UIKit and different one is from SwiftUI itself.
If I click on SwiftUI button, it’s working as anticipated. However after I click on UIKit button it’s not working as an alternative faucet gesture is triggering, motive the faucet gesture is enabled for VStack.

Learn how to make UIKit button motion works, if the faucet gesture is enabled?
I’ve to help my challenge from iOS 14 and faucet gesture ought to be enabled for VStack.

SwiftUI Code

var physique: some View {
        NavigationView {
            VStack {
                    .body(top: 100)
                Button("SwiftUI Button") {
                    debugPrint("SwiftUI Button Clicked")
            .onTapGesture {
                debugPrint("Person tapped")

Bridge Code

struct Bridge: UIViewRepresentable {
    func makeUIView(context: Context) -> some UIView {
        return UIKitButtonView()
    func makeCoordinator() -> Coordinator {
        return Coordinator()
    func updateUIView(_ uiView: UIViewType, context: Context) { }
    class Coordinator: NSObject {}

UIView Code

class UIKitButtonView: UIView {
    @IBOutlet var contentView: UIView!
    @IBOutlet var uikitButton: UIButton!
    override init(body: CGRect) {
        tremendous.init(body: body)
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been carried out")
    non-public func setup() {
        Bundle.predominant.loadNibNamed("UIKitButtonView", proprietor: self, choices: nil)
        contentView.body = self.bounds
        contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        contentView.body = self.bounds
    @IBAction func buttonAction(_ sender: Any) {
        debugPrint("UIKit button clicked")

enter image description here


Leave a Reply