Web page doesn't resize to presented view on iPad
AccuPhoenix01 opened this issue · 1 comments
AccuPhoenix01 commented
We are using SWKWV in multiple places. In this instance we have a presented modal dialog on iPad and when the webview is presented, it is inside of the presented modal (correct) but the size does not conform to the presented modal. The user is unable to pan sideways or pinch to reduce the size.
It appears here that maybe it should use the presenting view width, or app window width, instead of the screen width.
public override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
webView.frame = CGRect(x: 0, y: barHeight + topMargin,
width: UIScreen.main.bounds.width, <---------
Thanks
AccuPhoenix01 commented
Codefix that appears to work but surely has not been tested much:
public override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let superFrame = self.view.superview?.frame ?? UIScreen.main.bounds
webView.frame = CGRect(x: 0, y: barHeight + topMargin,
width: superFrame.width,
height: UIScreen.main.bounds.height - barHeight - topMargin)
backgroundBlackOverlay.frame = CGRect(x: 0,
y: -UIScreen.main.bounds.height,
width: UIScreen.main.bounds.width,
height: UIScreen.main.bounds.height * 2)
toolbar.frame = CGRect(x: 0, y: topMargin,
width: superFrame.width,
height: barHeight)
}