I’ve the next code:
struct ButtonTapTest: View {
let objects = [1, 2, 3]
var physique: some View {
Listing {
ForEach(objects, id:.self) { merchandise in
CellTestView()
}
}
}
}
struct CellTestView:View {
var physique: some View {
VStack {
Button {
print("TOP")
} label: {
Picture(systemName: "play.fill")
.font(.system(dimension: 40))
.foregroundColor(.pink)
}
.border(.pink)
Spacer()
Button {
print("BOTTOM")
} label: {
Picture(systemName: "play")
.font(.system(dimension: 40))
.foregroundColor(.pink)
}
.border(.yellow)
}
}
}
Creates the next display:
Drawback:
Each button actions get triggered within the cell no matter the place I faucet on the CellTestView
. I would like the person button actions to set off individually, every solely when its button will get tapped, and never once I faucet outdoors anyplace else on the cell.
You possibly can see within the gif beneath that it doesn’t matter the place I faucet on the CellTestView
, each button actions get set off regardless the place on the view I faucet, and each “TOP” and “BOTTOM” logs set off on the similar time.
How can I repair this so the 2 buttons within the cell obtain the faucet independently and solely when the faucet is contained in the associated button?