Post

Replies

Boosts

Views

Activity

Reply to NavigationSplitView in tvOS
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 } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’23
Reply to Unable to capture the view hierarchy
We had the same issue and resolved it my removing an extension to NotificationCenter to simplify listening for notifications. It held a let reference to NotificationCenter, and that seemed to break some magic with Objective-C message passing.
Replies
Boosts
Views
Activity
Aug ’23
Reply to NavigationSplitView in tvOS
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 } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’23