Swift SwiftUI、Listの1行内に2個のボタン配置はダメ、一緒に押下される
Code
import SwiftUI
struct ContentView: View {
var body: some View {
List() {
HStack {
Button(action: {
print("Push A!")
}, label: {
Text("A")
})
Button(action: {
print("Push B!")
}, label: {
Text("B")
})
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Result
Aボタンを押下
Push A! Push B!
Bボタンを押下
Push A! Push B!
どちらを押そうが一緒。
行が押されている為。
Formも一緒。
List・Formの役割からすれば当然か。
Toggleを複数配置するのは大丈夫です。





