5
import SwiftUI

struct ContentView: View {    
    var body: some View {
        NavigationLink(destination: DetailView()) {
            Text("Show Details")
        }
    }
}

struct DetailView: View {
    var body: some View {
        Text("Detailed")
    }
}

This code gives me a gray text (or button) saying 'Show Details' which is not touchable and does not perform the intended action (navigating to DetailView). Was there a change in the API or is it a bug?

I am using the newest versions of Xcode (Xcode 11 Beta 6 and macOS Catalina 10.15 Beta 6)

Prydwen
  • 531
  • 4
  • 11

1 Answers1

22

Your ContentView should have a NavigationView for NavigationLink to work, and be enclosed in some 'element', here a VStack

struct ContentView: View {    
    var body: some View {
        NavigationView {
            VStack {
                NavigationLink(destination: DetailView()) {
                     Text("Show Details")
                }
            }
        }
    }
}

Hope this helps!

fa65
  • 346
  • 2
  • 2