Fix iPad width hack breaking stretchy menus on iPhone
This commit is contained in:
parent
ae0c91d719
commit
1e95c7d153
|
@ -81,10 +81,12 @@ class ReadViewController: UIViewController {
|
||||||
webView.scrollView.alwaysBounceHorizontal = false
|
webView.scrollView.alwaysBounceHorizontal = false
|
||||||
view.addSubview(webView)
|
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([
|
NSLayoutConstraint.activate([
|
||||||
webView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
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: webViewWidthFix),
|
||||||
webView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -0.5),
|
|
||||||
webView.topAnchor.constraint(equalTo: view.topAnchor),
|
webView.topAnchor.constraint(equalTo: view.topAnchor),
|
||||||
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in New Issue