We have got a lot of tutorials for iOS with code like this:
List(items) { item in
NavigationLink(destination: ItemView(item: item)) {
ItemRow(item: item)
}
}
On macOS however, this code results in a list of disabled table cell views.
So how do we build something like NSTableView
using SwiftUI?
In order to use NavigationLink
, you’ll need to be in a NavigationView
context.
Wrapping your current view hierarchy in a NavigationView
should fix your issue.
NavigationView {
List(items) { item in
NavigationLink(destination: ItemView(item: item)) {
ItemRow(item: item)
}
}
}