I\'m working on adding a new reading view to my browser app. It is another view controller, that only includes a WKWebView added as a subview with a button (and gesture) to clos
I managed to solve the problem by using this line of code:
self._webView!.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
:)
I'm posting an answer for Objective-C, just in case if someone comes here looking for it
[self.webView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];
swift 3 version:
webView?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
In fact, as WKWebView can only be added programmatically, it happens to have the autoresizing mask to constraints flag enabled by default (when adding components and constraints inside Interface Builder, it's usually disabled for you). I think the correct solution would be:
webView?.translatesAutoresizingMaskIntoConstraints = false
after adding the constraints/anchors.