Fix iPad width hack breaking stretchy menus on iPhone

This commit is contained in:
Shadowfacts 2022-06-22 16:04:01 -04:00
parent ae0c91d719
commit 1e95c7d153
1 changed files with 4 additions and 2 deletions

View File

@ -81,10 +81,12 @@ class ReadViewController: UIViewController {
webView.scrollView.alwaysBounceHorizontal = false
view.addSubview(webView)
// subtract 0.5, because otherwise, on ipad, the web view's scroll content view ends up being wider than the scroll view itself, causing the content to bounce horizontally
let webViewWidthFix = UIDevice.current.userInterfaceIdiom == .pad ? -0.5 : 0
NSLayoutConstraint.activate([
webView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
// subtract 0.5, because otherwise, on ipad, the web view's scroll content view ends up being wider than the scroll view itself, causing the content to bounce horizontally
webView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -0.5),
webView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: webViewWidthFix),
webView.topAnchor.constraint(equalTo: view.topAnchor),
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])