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 Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

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.