Post

Replies

Boosts

Views

Activity

Push new views to sidebar when using NavigationPath
I have an existing app that uses NavigationSplitView with a detail view that is never changed and just updates to show changes in data. All navigation changes the sidebar only using NavigationLinks with .isDetailLink(false). Now I'm wanting to use NavigationPath with a simple router and enums. import SwiftUI @main struct NavRouterApp: App { @State private var router = Router() var body: some Scene { WindowGroup { NavigationStack(path: $router.navPath) { ContentView() .navigationDestination(for: AppRoute.self) { route in switch route { case .citizens: ContentView() .environment(router) case .citizen: EmptyView() .environment(router) case .tasform2: TASForm2View() .environment(router) case .start: StartView() .environment(router) case .editcharacteristics: EmptyView() .environment(router) case .basicdata(let citizen): BasicDataView(citizen: citizen) .environment(router) .navigationBarBackButtonHidden(true) case .characteristics: EmptyView() .environment(router) } } } .environment(router) } } } The problem is that pushing a subview now replaces the entire content instead of just the sidebar. Pushing a subview with NavigationSplitView would update the sidebar as desired but I would have to replace the detail view, which is not a good idea. I haven't been able to find any way to accomplish what I want. Suggestions?
Topic: UI Frameworks SubTopic: SwiftUI
1
0
24
20h
Capture a List selection AND push a view
I've got a situation where I want the iPad to push an editing view onto the sidebar (like on iPhone) and also display a detail view (no content view). This is working great. However, I need to determine which item from a List in a NavigationSplitView has been selected and pass this to the detail view (the selection is out of scope). This works with the List selection parameter, but the item selected is ONLY selected and the child view in the NavigationLink does not get pushed, nor does the detail view get changed. I either need to figure out a way to capture the selection without the List Selection parameter (Tap Gesture?) or get the navigation to happen even when using the Selection parameter. I'd appreciate some ideas as I'm a newb just learning SwiftUI.
Topic: UI Frameworks SubTopic: SwiftUI
0
0
60
Dec ’25
SwiftUI Tutorial Question
In the ScoreKeeper tutorial there's the following code: ForEach($players) { $player in GridRow { TextField("Name", text: $player.name) Text("\(player.score)") Stepper("\(player.score)", value: $player.score) .labelsHidden() } } Can someone please explain why the 2 instances of "player.score" are not preceded by "$". Thanks!
0
0
269
Sep ’25
Push new views to sidebar when using NavigationPath
I have an existing app that uses NavigationSplitView with a detail view that is never changed and just updates to show changes in data. All navigation changes the sidebar only using NavigationLinks with .isDetailLink(false). Now I'm wanting to use NavigationPath with a simple router and enums. import SwiftUI @main struct NavRouterApp: App { @State private var router = Router() var body: some Scene { WindowGroup { NavigationStack(path: $router.navPath) { ContentView() .navigationDestination(for: AppRoute.self) { route in switch route { case .citizens: ContentView() .environment(router) case .citizen: EmptyView() .environment(router) case .tasform2: TASForm2View() .environment(router) case .start: StartView() .environment(router) case .editcharacteristics: EmptyView() .environment(router) case .basicdata(let citizen): BasicDataView(citizen: citizen) .environment(router) .navigationBarBackButtonHidden(true) case .characteristics: EmptyView() .environment(router) } } } .environment(router) } } } The problem is that pushing a subview now replaces the entire content instead of just the sidebar. Pushing a subview with NavigationSplitView would update the sidebar as desired but I would have to replace the detail view, which is not a good idea. I haven't been able to find any way to accomplish what I want. Suggestions?
Topic: UI Frameworks SubTopic: SwiftUI
Replies
1
Boosts
0
Views
24
Activity
20h
Capture a List selection AND push a view
I've got a situation where I want the iPad to push an editing view onto the sidebar (like on iPhone) and also display a detail view (no content view). This is working great. However, I need to determine which item from a List in a NavigationSplitView has been selected and pass this to the detail view (the selection is out of scope). This works with the List selection parameter, but the item selected is ONLY selected and the child view in the NavigationLink does not get pushed, nor does the detail view get changed. I either need to figure out a way to capture the selection without the List Selection parameter (Tap Gesture?) or get the navigation to happen even when using the Selection parameter. I'd appreciate some ideas as I'm a newb just learning SwiftUI.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
60
Activity
Dec ’25
SwiftUI Tutorial Question
In the ScoreKeeper tutorial there's the following code: ForEach($players) { $player in GridRow { TextField("Name", text: $player.name) Text("\(player.score)") Stepper("\(player.score)", value: $player.score) .labelsHidden() } } Can someone please explain why the 2 instances of "player.score" are not preceded by "$". Thanks!
Replies
0
Boosts
0
Views
269
Activity
Sep ’25