考虑NavigationView中的列表,如下所示:
struct ContentView: View {
var body: some View {
NavigationView {
List {
Text("Shovel")
Text("Bucket")
Text("Sieve")
}.navigationTitle("Sandbox")
}
}
}
我想在列表条目的后缘添加.swipeActions
,如下所示:
Text("Shovel")
.swipeActions(edge: .trailing) {
Button{} label: { Image(systemName: "trash.fill") }
}
但一旦我将列表条目嵌入到NavigationLink
中,.swipeActions
就不起作用了.
NavigationLink(destination: Text("Shovel")) {
Text("Shovel")
.swipeActions(edge: .trailing) {
Button{} label: { Image(systemName: "trash.fill") }
}
}
现在谈谈这个问题:
为什么会这样?我怎样才能同时拥有这两个功能?
谢谢你的帮助.