我有一个包含在NavigationView
中的NavigationLink
列表。现在我想通过ContextMenu
扩展视图,其中包含一个元素,在我的导航堆栈中显示另一个视图。
struct MainView: View {
@State var elements = ["Hello", "World"]
var body: some View {
NavigationView {
List(elements, id: \.self, rowContent: { element in
NavigationLink(destination: PresentView(element: element)) {
Text(element)
.contextMenu {
NavigationLink(
"Edit",
destination: EditView(element: element)
)
}
}
})
}
}
}
我的项目中普通点击的导航工作正常,但是在Xcode 11 Beta 5中上下文菜单却停止了工作。我遇到了以下错误:[WindowServer] display_timer_callback: unexpected state。
我应该如何从上下文菜单中推入一个新视图到我的导航堆栈?
NavigationLink
,并在我的导航视图中设置了一个状态来推送新视图。 - jlsiewert