If anyone comes across this in the future, I solved this problem with the following:
struct View1: View{
@State var KeepView2: Bool = false
var body: some View{
if self.KeepView2{
NavigationLink(destination: View2(keepViewOpen: self.$keepView2), isActive: self.$keepView2){
Text("Navigate")
}
}
}
}
struct View2: View{
@Binding keepViewOpen: Bool
var body: some View{
VStack{
Text("Hello World")
}.onAppear{
self.keepViewOpen = true
}
}
}
If anyone comes across this in the future, I solved this problem with the following:
struct View1: View{
@State var KeepView2: Bool = false
var body: some View{
if self.KeepView2{
NavigationLink(destination: View2(keepViewOpen: self.$keepView2), isActive: self.$keepView2){
Text("Navigate")
}
}
}
}
struct View2: View{
@Binding keepViewOpen: Bool
var body: some View{
VStack{
Text("Hello World")
}.onAppear{
self.keepViewOpen = true
}
}
}