I would like to use an NSBrowser
in a MacOS app that is SwiftUI based. To that end, I created a view that implements NSViewRepresentable
. My protocol methods are super basic:
func makeNSView(context: Context) -> NSBrowser {
let browser = NSBrowser()
browser.delegate = context.coordinator
return browser
}
func updateNSView(_ nsView: NSBrowser,
context: NSViewRepresentableContext<RoomBrowser>) {
}
The problem I am having is that the NSBrowser
doesn't grow to fill the frame of the hosting View
. The width seems fine, but the height is wrong.
Looking at the view debugger in Xcode, I can see the there is a "Host View" which is 22 points tall and the NSBrowser
is has layout constraints so the height of the browser matches the height of the "Host View".
If I try to resize the window (which hugs the content pretty tightly) I can make the window a little smaller, but it will not drag larger.
How can I change the size of the host view to manipulate the size of the NSBrowser
?