Posts

Post marked as solved
11 Replies
0 Views
Until (one would hope) Apple gets around to it, here's something that'll work. Using Debug View Hierarchy in the debug toolbar, I found that a private NSSplitViewController is being used for layout. I opted to pass an action down the responder chain to toggle its associated sidebar:     private func documentGroup() -> some Scene {         return DocumentGroup(newDocument: Document()) {             DocumentView()                 .toolbar {                     ToolbarItem(placement: .navigation) {                         Button(action: toggleSidebar, label: {                             Image(systemName: "sidebar.left")                         })                     }                 }                 .environmentObject($0.document.store)         }     }     private func toggleSidebar() {         #if os(iOS)         #else         NSApp.keyWindow?.firstResponder?.tryToPerform(#selector(NSSplitViewController.toggleSidebar(_:)), with: nil)         #endif     } One might also be able to use a package like Swift-Introspection to get a handle on the NSSplitViewController in your SwiftUI code and send the message more directly.
Post not yet marked as solved
13 Replies
0 Views
Ah - likely something left over from experimentation...
Post not yet marked as solved
13 Replies
0 Views
struct ContentView : View { @State var width: Length = 1 var body: some View { GeometryReader { geometry in ScrollView(isScrollEnabled: true, alwaysBounceHorizontal: false, alwaysBounceVertical: true, showsHorizontalIndicator: false, showsVerticalIndicator: true) { VStack { Text("This is a test of the emergency broadcast system. This is only a test. If this were a real emergency, then you'd be up the creek without a paddle. But it's not so you're safe for the time being.") .background(Color.red) .lineLimit(nil) .frame( minWidth: geometry.size.width, idealWidth: geometry.size.width, maxWidth: geometry.size.width, minHeight: geometry.size.height, idealHeight: geometry.size.height, maxHeight: .infinity, alignment: .topLeading) } } } } }The above appears to work, and on further experimentation, I've found both that the VStack is unnecessary, and that one can omit `idealWidth` and `idealHeight`