I have my web view displaying correctly, but I've run into a problem in getting the auto layout constraints working correctly. Basically, I build the appropriate web view as a subview of a custom view, which is in turn embedded in a view within a window. The problem is that, if I set constraints on the custom view, the window stops being resizable, and I can't work out why.
Here's the code for the constraints:
let variableBindings = ["webView": webView]
let constraints1 = NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[webView]-0-|", options: [], metrics: nil, views: variableBindings)
let constraints2 = NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[webView]-0-|", options: [], metrics: nil, views: variableBindings)
webContentView.addConstraints(constraints1)
webContentView.addConstraints(constraints2)
I have very similar code for the actual web view within its containing view. If I have only those and not the outer constraints, the window is resizable, but the container for the web view doesn't resize.
I must be doing something wrong, obviously, but I have run out of ideas on how to find my problem. Needless to say, this is the first time I've had to do auto layout in code.
Thanks for any insights,
John
--
John Brownie
Mussau-Emira language, New Ireland Province, Papua New Guinea
Kouvola, Finland