1

I am currently trying to use iOS16's NavigationLink to show detail views for my list items, but for some reason the items seem to be disabled - does anyone know why this is happening?

NavigationLink(value: example) {
    ListRowView(title: example.title,
                subtitle: example.subtitle)
}
.navigationDestination(for: CollectionItem.self) { example in
    Text(example.title)
}

enter image description here

Mitemmetim
  • 520
  • 3
  • 12

1 Answers1

1

I forgot to replace the NavigationView with the new NavigationStack.

Even though the answer is pretty obvious, it will still maybe overlooked more often. So the final code would look like this:

NavigationStack {
    List {
      // ...
        ForEach(viewModel.examples) { example in
            NavigationLink(value: example) {
                ListRowView(title: example.title,
                            subtitle: example.subtitle)
            }
        }
      // ...
    }
    .navigationDestination(for: CollectionItem.self) { example in
        Text(example.title)
    }
    .navigationTitle(viewModel.title)
}
Mitemmetim
  • 520
  • 3
  • 12