The SwiftUI cookbook for navigation

RSS for tag

Discuss the WWDC22 Session The SwiftUI cookbook for navigation

Posts under wwdc2022-10054 tag

7 Posts
Sort by:
Post not yet marked as solved
5 Replies
4.4k Views
Any one getting any issues with NavigaitonLink to seemingly innocuous views freezing when tapped on? 1 CPU at 100% memory steadily increasing until app gets killed by the system. Will freeze if any NavigationLink on the view is tapped if certain views are linked to using NavigaitonLink. I note some people have been getting similar freezes if they use @AppStorage, but I'm not using @AppStorage. I do use CoreData tho. tho I have some views that use core data that don't freeze. https://developer.apple.com/forums/thread/708592?page=1#736374022 has anyone experienced similar issues? or know the cause. it doesn't seem to be any of my code because if I pause the debugger it stops on system code.
Posted
by ngb.
Last updated
.
Post not yet marked as solved
1 Replies
1.1k Views
Overview On macOS, in a NavigationSplitView when the menu button is added to the detail view toolbar, it seems to look disabled Environment Xcode: 14.1 beta 3 (14B5033e) macOS: 13.0 Beta (22A5365d) Code: struct ContentView: View { @State private var selectedNumber: Int? var body: some View { NavigationSplitView { List(0..<100, selection: $selectedNumber) { number in Text("cell \(number)") } } detail: { Text("Detail") .toolbar { ToolbarItem { Menu { Button("aa") {} Button("bb") {} } label: { Label("Add Bookmark", systemImage: "book") } } } } } } Steps to reproduce: Run the project on macOS Select cell 0 on the sidebar Click on the book toolbar button and notice the menu appear Select cell 1 on the sidebar Expected Behaviour After step 4, the book toolbar button should look prominent (like it is enabled) Actual Behaviour After step 4, the book toolbar button looks like it is disabled. Screenshot
Posted
by newwbee.
Last updated
.
Post not yet marked as solved
4 Replies
4.1k Views
I'm trying to implement the same UI used by the Settings app on iPad: a split view with two columns that are visible at all times. This code produces the layout i want, but I would like to hide the "toggle sidebar visibility" button that the system introduces. Is there a SwiftUI API I can use to hide this button? Maybe an alternate way to setup views that tells the system that the button is not necessary? struct SomeView: View { var body: some View { NavigationSplitView( columnVisibility: .constant(.all), sidebar: { Text("sidebar") }, detail: { Text("detail") } ) .navigationSplitViewStyle(.balanced) } }
Posted
by Matteo.
Last updated
.
Post not yet marked as solved
6 Replies
1.4k Views
I'm using a two column NavigationSplitView, where the view passed for the detail column is the root of a NavigationStack. The navigation works as expected, but the navigationTitle and toolbar elements of the detail view are very slightly delayed when the view appears on iOS, such that they 'pop' in rather than smoothly animating like normal. Returning to the root of the view from views higher in this stack animates as expected. Has anyone seen anything like this before? Thanks!
Posted Last updated
.
Post marked as solved
3 Replies
2.3k Views
I am currently learning to create multiplatform applications using SwiftUI and NavigationSplitView, and I faced the problem of arranging different Views in the same App. Let's open the default Notes application, and here, we can see a switch between two and three-column views of the content. So my question is, how to arrange this kind of view for different App pages using NavigationSplitView? First page has two columns interface Second has three columns
Posted
by bravelver.
Last updated
.
Post not yet marked as solved
1 Replies
1.5k Views
I am currently trying to build a NavigationManager with programmatic navigation. For that I'm using the NavigationPath combined with NavigationDestination. Sadly facing the following issue: navigationDestionation is not being recognised when located in sheet. Im receiving the following message when trying to update the path of the NavigationStack within the sheet. A NavigationLink is presenting a value of type “PathType” but there is no matching navigationDestination declaration visible from the location of the link. The link cannot be activated. Note: Links search for destinations in any surrounding NavigationStack, then within the same column of a NavigationSplitView. Here is some simplified code snipped of the implementation. struct RootView: View { @State private var isPresented: Bool = true var body: some View { Button("Open Modal", action: { self.isPresented.toggle() }) .sheet(isPresented: self.$isPresented, content: { ModalContent() }) } } private struct ModalContent: View { @State private var path = NavigationPath([PathType.configuration]) var body: some View { NavigationStack(path: self.$path) { VStack { Text("Placeholder") } .navigationDestination(for: PathType.self) { pathType in switch pathType { case .configuration: Text("Configuration") default: Color.red } } } } }
Posted
by vazu.
Last updated
.
Post not yet marked as solved
1 Replies
564 Views
Hi! When using the Sample "NavigationCookbook" in the two column layout, the selection in the first column is not remembered, when navigating to the Home Screen and back. This behaviour can be reproduced by starting the app on the iPad or simulator, selecting for example "Pancake" and then navigating to the home screen and back into the navigation. Sometimes this (the navigation to/back from the home screen) has to be done twice, to lose the selection. In the console log you can see the message "Update NavigationAuthority bound path tried to update multiple times per frame." appearing. Not sure if this has something todo with the selection being lost. This is on iOS 16.4.1 not sure if the behaviour before was different. Anybody experiences the same behaviour? Bug in SwiftUI or in the sample app? Cheers, Michael
Posted
by milutz.
Last updated
.