Post

Replies

Boosts

Views

Activity

Reply to Mac Big Sur app with sidebar clears NavigationLink view
Solved this. In the primary navigationView, you have to include a placeholder view for the detail view. See below for an example. Without the Text("Select a link...") view, the problem occurs. struct ContentView: View { 		var body: some View { 				NavigationView { 						List { 								ForEach(1 ... 10, id: \.self) { index in 										NavigationLink(destination: 																		Text("\(index)") 																		 .frame(maxWidth: .infinity, maxHeight: .infinity) 										) { 												Text("Link \(index)") 										} 								} 						} 						.listStyle(SidebarListStyle()) 						Text("Select a link...") 								.frame(maxWidth: .infinity, maxHeight: .infinity) 				} 				.frame(maxWidth: .infinity, maxHeight: .infinity) 		} }
Jul ’20
Reply to Selection disappearing in NSTableView inside SwiftUI
I ran into this too, but managed to find a solution. The updateNSView method. was getting called very frequently and so reloading the table which lost the section. I made this function check if its data had changed before reloading and that worked. I had passed the data to the Coordinator for use in the data source & delegate, so this code worked for me:   func updateNSView(_ nsView: NSTableView, context: Context) {     if tableData != context.coordinator.tableData {       context.coordinator.tableData = tableData       nsView.reloadData()     }   } The elements in my data array were already Equatable, so this works fine.
Jul ’22