WKWebView added as Subview is not resized on rotation in Swift

前端 未结 4 1024
眼角桃花
眼角桃花 2021-02-04 05:41

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

4条回答
  •  醉酒成梦
    2021-02-04 06:17

    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.

提交回复
热议问题