Reputation: 151
I use ZStack & NaviagtonLink in SwiftUI.
ZStack{
List{
NavigationLink(destination: NextView()) {
Text("Hi")
}
}
Text("Hello")
}
This view is valid as I expected, and there are the text "Hello" on List's columns.
But even in NavigationLink ZStack is valid and in NextView there is hello.
I want to display it only this view, and I don't want to display it in NextView,
Please tell me how to fix.
Thank you.
Upvotes: 1
Views: 382
Reputation: 882
Embed in navigationView otherwise navigation link cannot work
struct ContentView: View {
var body: some View {
NavigationView{
ZStack{
List{
NavigationLink(destination: NextView()) {
Text("Hi")
}
}
Text("Hello")
}
.navigationBarHidden(true)
}
}
}
Upvotes: 2