小编Jak*_*aps的帖子

Make a list row selectable in SwiftUI

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)
}
Run Code Online (Sandbox Code Playgroud)

When I tap on one of the items, nothing happens. If I create a simple list with storyBoards, I get the behavior I want:

期望的行为

ios swift swiftui

4
推荐指数
1
解决办法
3318
查看次数

标签 统计

ios ×1

swift ×1

swiftui ×1