Inspectors in SwiftUI: discover the details

RSS for tag

Discuss the WWDC23 Session Inspectors in SwiftUI: discover the details

View Session

Posts under wwdc2023-10161 tag

4 Posts
Sort by:
Post not yet marked as solved
1 Replies
617 Views
Should this not set the inspector width to 550 every time? TableView() .inspector(isPresented: $state.presented) { InspectorFormView(selection: model[state.selection]) .inspectorColumnWidth(min: 150, ideal: 550, max: 600) } This is almost verbatim from the WWDC video (10161). This ideal parameter will be the size of the column at at first launch, but if the user resizes the inspector, the system will persist that size across launches. Inspector uses the minimum width (150) in every case. How can the ideal width be guaranteed upon initial launch? I could set the minimum to 550, but I'd like the user to be able to reduce the size of the inspector as well ... Thanks much & keep inspecting!🧐 (Sonoma, beta 5 / Xcode beta 6)
Posted
by KiraDog.
Last updated
.
Post marked as solved
1 Replies
503 Views
I'm using the new SwiftUI Inspector API. Is it possible to disable the ability to collapse the inspector (when dragging the mouse cursor on the ionspector splitter)? Also, as a workaround, when the inspector is collapsed, I didn't find how I could expand the inspector programmatically? import SwiftUI struct SampleContentView: View { @State var inspectorPresented = true var body: some View { NavigationStack() { Text("Main View") .inspector(isPresented: $inspectorPresented, content: { Text("Inspector") .inspectorColumnWidth(200) }) } } }
Posted
by benoit.
Last updated
.
Post not yet marked as solved
0 Replies
756 Views
During WWDC Q&As I asked how I could add an inspector to my UIKit app that’s using UISplitViewController with a double column style featuring a sidebar and detail view controller. I initially tried a full-height inspector (by putting my split view controller into a SwiftUI view and applying the inspector on that, embedding that into a UIHostingController to be the rootViewController) but this caused a bunch of UI bugs (seemingly related to optimizations made for a size class that doesn’t match the actual appearance) and it doesn’t extend into the NSToolbar on Mac Catalyst anyways. I now want to try implementing the under-the-toolbar solution. An engineer said: For an under toolbar appearance, you should be able to use .inspector on the detail view controller (after wrapping it in a SwiftUI view), but you may have to do manual toolbar management here (hiding and showing) to make sure you don't end up with stacked toolbars/UINavigationBars I have indeed run into the problem with two navigation bars in my inspector. I want to keep the navigation bar visible in the detail screen, but I do not want any navigation bars visible in my inspector since I’m going to provide my own button to toggle the inspector (via a button in the detail on iOS and an NSToolbarItem on macOS). Is this layout possible? I tried applying .toolbar(.hidden) on the inspector’s view but this doesn’t do anything, there’s still two stacked navigation bars (tested on iPadOS 17 beta 2). I think even if that worked it would only hide the inner navigation bar, I’d still have an undesirable navigation bar. :/ Wishing there were a UIKit API I could avoid the interop complexity ha In the sample project attached to FB12447791, the root view controller is a UISplitViewController. The primary view controller is a UINavigationController containing a sidebar. The secondary view controller is a UINavigationController containing a UIHostingController whose root view is a SecondaryColumnView. SecondaryColumnView is a Form that has a button to Toggle Inspector, a navigation title, and an inspector. The inspector is a Form that has .toolbar(.hidden). I've provided several screen recordings in the feedback report as well. Thanks for your help and insight!
Posted
by Jordan.
Last updated
.
Post not yet marked as solved
0 Replies
712 Views
I have a UIKit Mac Catalyst app, optimized for Mac idiom, with an NSToolbar manually added to the windowScene. Is it possible to implement a full-height inspector sidebar with this setup? It seems to always appear underneath the toolbar in my testing. Even if I remove my NSToolbar and let the system create a toolbar from a NavigationStack. It works on iOS - stretches all the way up the window splitting the app into two columns. var body: some View { NavigationStack { AnimalTable(state: $state) .inspector(isPresented: $state.inspectorPresented) { AnimalInspectorForm(animal: $state.binding()) } .toolbar { Button { state.inspectorPresented.toggle() } label: { Label("Toggle Inspector", systemImage: "info.circle") } } } }
Posted
by Jordan.
Last updated
.