NavigationSplitView in tvOS

Has anyone been able to use NavigationSplitView in tvOS?

I tried building something dead-simple like the example on https://developer.apple.com/documentation/swiftui/navigationsplitview and it just doesn't work on tvOS.

It shows the list of entries, but none of them seem to highlight (although I can hear sounds as if the focus is changing), and clicking the button to select them does nothing.

If I start with a default selection, it starts by showing the detail, and the menu button will take me to the list, but again focus appears and nothing can be selected (other than the bloop sounds that hint the focus is changing).

Post not yet marked as solved Up vote post of electrollama Down vote post of electrollama
1.3k views

Replies

I think I have the very same problem: I used the sample code from the documentation and can see the the list of entries on the left on tvOS:

However, no element is selected/focused, hence you are stuck in the the screen.

I tried setting a default element in onAppear by initially setting the selection of the NavigationSplitView, however this results in instantly opening the first detail.

When you return then the MENU button (on the remote), you end up again in the list screen, no element focused and no element focussable.

The corresponding code:

struct LogView: View {

    @Environment(\.dismiss) private var dismiss

    var viewModel: LogViewModel

    @State private var entryId: LogEntry.ID?

    var body: some View {
            NavigationSplitView {
                List(viewModel.entries, selection: $entryId) { entry in
                    LogEntryView(entry: entry)
                }
            } detail: {
                Group {
                    if let entry = viewModel.entry(id: entryId) {
                        // Detail view
                    }
                }
            }
     }
}

Same problem here Did you manage to fix it?