I'm creating a list with custom rows in SwiftUI. When I tap one of them, I want the row to turn light gray until another tap is detected.
This doesn't happen with simple non-custom lists either.
Here's my list:
List{
ForEach(blocks){ block in
BlockRow(block: block)
}
.onDelete(perform: delete)
.onMove(perform: day.move)
}
When I tap on one of the items, nothing happens. If I create a simple list with storyBoards, I get the behavior I want:
Hey so you asked this 3 months ago so I hope you got an answer somewhere or figured it out since then, but to get to the good stuff to make a button tappable I was able to get it working using this,
List {
Button (action: {
//Whatever action you want to perform
}) {
//Code to present as the cell
}
}
I would maybe try the following based on your code,
List (blocks) { block in
Button (action: {
//perform button action
}) {
//How the cell should look
BlockRow(block: block)
}
}
.onAppear()
.onDelete()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With