Two Buttons inside HStack taking action of each other

后端 未结 1 442
野趣味
野趣味 2020-12-09 20:05

I have created a simple List with a horizontal stack view (label, button, button). each button has his own button action but when I run I can see tap on one button print two

相关标签:
1条回答
  • 2020-12-09 21:03

    Need to use onTapGesture instead of action like this way.

    Button(action: {}) {
        Text("watch")
    }
    .frame(minWidth: 0, maxWidth: .infinity)
    .background(Color.red)
    .onTapGesture {
        print("watch")
    }
    
    0 讨论(0)
提交回复
热议问题