UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Form's Button in childView does not seems to be working

Forums > SwiftUI

Hi Guys,

I have a Button() inside a form from a child view (as described it the code below). And it does not seems to be working ( using .onTapGesture works... but that not cool)

Have any of you encountered this proble before ? is there a better solution than onTapGesture ?

Thanks

Tim

PrimaryView{
VStack{
    if self.mode?.wrappedValue == .inactive {
       ChildView()
     }
}

ChildView{
  Form{
    HStack{
        Button(action:{
           //do something...
        }){
          Text("Do it")
        }
    }
  }
}

2      

Hi,

I have faced such issue once and I solved it by adding frame to it.

You can try like this,

    Button(action:{
       //do something...
    }){
      Text("Do it")
      .frame(width: 200, height: 200)
    }

2      

@iRiziya thanks, i think what you're pointing out here is a lack of padding a the "touch" surface beeing too small to be detected.. but my problem doesn't seems to be here. I've solved it out by removing the Form

2      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.