Post

Replies

Boosts

Views

Activity

Reply to `NSBrowser` inside `NSViewRepresentable`
I had the same issue and found that if you wrap the NSBrowser instance in a container NSView and set its layout constraints to match the container's bounds, the NSBrowser takes on the correct size: public func makeNSView(context: Context) -> NSView { let browser = NSBrowser() browser.delegate = context.coordinator let container = NSView() container.addSubview(browser) browser.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ browser.topAnchor.constraint(equalTo: container.topAnchor), browser.leadingAnchor.constraint(equalTo: container.leadingAnchor), browser.trailingAnchor.constraint(equalTo: container.trailingAnchor), browser.bottomAnchor.constraint(equalTo: container.bottomAnchor) ]) return container }
May ’23