Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web page doesn't resize to presented view on iPad #7

Open
AccuPhoenix01 opened this issue Jul 25, 2022 · 1 comment
Open

Web page doesn't resize to presented view on iPad #7

AccuPhoenix01 opened this issue Jul 25, 2022 · 1 comment

Comments

@AccuPhoenix01
Copy link

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,   <---------

IMG_5CF0D956F4BC-1

Thanks

@AccuPhoenix01
Copy link
Author

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)
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant