[ad_1]
In SwiftUI I’ve a VStack with faucet gesture enabled. And this VStack Comprises 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 isn’t working as an alternative faucet gesture is triggering, cause the faucet gesture is enabled for VStack.
How one can make UIKit button motion works, if the faucet gesture is enabled?
I’ve to assist my mission from iOS 14 and faucet gesture needs to be enabled for VStack.
SwiftUI Code
var physique: some View {
NavigationView {
VStack {
Bridge()
.body(top: 100)
Button("SwiftUI Button") {
debugPrint("SwiftUI Button Clicked")
}
}
.onTapGesture {
debugPrint("Consumer tapped")
}
}
.navigationViewStyle(StackNavigationViewStyle())
}
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)
setup()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been applied")
}
personal func setup() {
Bundle.important.loadNibNamed("UIKitButtonView", proprietor: self, choices: nil)
addSubview(contentView)
contentView.body = self.bounds
contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
contentView.body = self.bounds
}
@IBAction func buttonAction(_ sender: Any) {
debugPrint("UIKit button clicked")
}
}
[ad_2]

