struct Testing: View {
var body: some View {
NavigationView{
VStack {
Text("View 1")
Text("View 1.3")
NavigationLink(destination: TestView(),
label: {
Text("View 1 navigation")
})
}
}
}
}
struct TestView: View {
var body: some View {
VStack {
Text("View 2")
}
.navigationBarItems(trailing:NavigationLink(
destination: Text("View 3"),
label: {
Text("Navigate")
}))
}
}
在TestView的navigationBarItems中点击NavigationLink,它会导航到View 3。但是当我点击返回按钮时,它不会返回到TestView,而是直接返回Testing。
我该如何使其返回到先前的视图而不是第一个视图?
我正在使用Xcode 12。