From 1e95c7d15369fbd98b3cec7dc388711138b7330c Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 22 Jun 2022 16:04:01 -0400 Subject: [PATCH] Fix iPad width hack breaking stretchy menus on iPhone --- Reader/Screens/Read/ReadViewController.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Reader/Screens/Read/ReadViewController.swift b/Reader/Screens/Read/ReadViewController.swift index 0477fc0..24f3adb 100644 --- a/Reader/Screens/Read/ReadViewController.swift +++ b/Reader/Screens/Read/ReadViewController.swift @@ -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), ])