Hi there,
I'm struggling with the new NavigationSplitView.
struct Team: Identifiable, Hashable {
let id = UUID()
var name: String
var players: [String]
}
struct SplitView3: View {
@State private var teams = [
Team(name: "Packers", players: ["Rodgers", "Alexander", "Dillon"]),
Team(name: "Vikings", players: ["Ingram", "Cousins", "Berry"])
]
@State private var selectedTeam: Team?
@State private var selectedPlayer: String?
var body: some View {
NavigationSplitView {
List(teams, selection: $selectedTeam) { team in
Text(team.name).tag(team).navigationTitle("Team")
}.navigationBarHidden(true)
.navigationSplitViewColumnWidth(250)
} content: {
List(selectedTeam?.players ?? [], id: \.self, selection: $selectedPlayer) { player in
Text(player).navigationTitle("Team Member")
}
} detail: {
Form{
Text(selectedPlayer ?? "Choose a player.")
}
.navigationTitle("Player Detail").navigationBarTitleDisplayMode(.inline)
}
.navigationSplitViewStyle(.automatic)
}
}
When I run this in Simulator or Canvas I can navigate from Team (sidebar), trough Teammembers (content) to detail view and back to sidebar.
But after I reach the sidebar again the links forward to content view don't work anymore.
Did I miss something?