I can not get a NavigationLink
in SwiftUI. The button is visible, but unfortunately this is gray and can not be clicked.
Here is the code:
import SwiftUI
import Combine
struct ContentView: View {
var body: some View {
NavigationView{
NavigationLink(destination: Text("Detail for Test")) {
Text("Test")
}.navigationBarTitle("Select a user")
}
}
}
Does anyone know the problem?
It seems the problem is related to the fact that you have added the
NavigationLink
inside theNavigationView
without defining a layoutIn fact, if you add a
VStack
, everything works correctlyThe error is related to a missing view in your NavigationLink statement.