Post

Replies

Boosts

Views

Activity

Reply to SwiftUI : NavigationStack in new iOS 18 TabView pushes twice when path in parameter
In my case, a successful workaround has been moving my convenience modifier around navigationDestination to be used directly within the NavigationStack. Broken example: NavigationStack(path: $navModel.myFarmTabPath) { MyRootScreen() .appNavigationDestinations() // <- My wrapper around destination selection } Working example: NavigationStack(path: $navModel.myFarmTabPath) { MyRootScreen() .navigationDestination(for: Screen.self) { screen in return screen.representedDestination } } To keep things tidy and allow for easier re-use in my tab views, I've added an extension to Screen which returns a destination: extension Screen { @ViewBuilder var representedDestination: some View { switch self { case .screenOne: ScreenOne() case .screenTwo: ScreenTwo() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’24
Reply to SwiftUI : NavigationStack in new iOS 18 TabView pushes twice when path in parameter
In my case, a successful workaround has been moving my convenience modifier around navigationDestination to be used directly within the NavigationStack. Broken example: NavigationStack(path: $navModel.myFarmTabPath) { MyRootScreen() .appNavigationDestinations() // <- My wrapper around destination selection } Working example: NavigationStack(path: $navModel.myFarmTabPath) { MyRootScreen() .navigationDestination(for: Screen.self) { screen in return screen.representedDestination } } To keep things tidy and allow for easier re-use in my tab views, I've added an extension to Screen which returns a destination: extension Screen { @ViewBuilder var representedDestination: some View { switch self { case .screenOne: ScreenOne() case .screenTwo: ScreenTwo() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to iOS 18 beta bug: NavigationStack pushes the same view twice
I have the same issue on iOS beta 7. Our affected app can't use the workaround, since we need to be able to inspect the navigation path items. I have filed a radar: FB14936419
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’24