diff --git a/iOS/Article/ContextMenuPreviewViewController.swift b/iOS/Article/ContextMenuPreviewViewController.swift index f3b67be0d..3b7e18219 100644 --- a/iOS/Article/ContextMenuPreviewViewController.swift +++ b/iOS/Article/ContextMenuPreviewViewController.swift @@ -42,9 +42,24 @@ class ContextMenuPreviewViewController: UIViewController { dateFormatter.timeStyle = .medium dateTimeLabel.text = dateFormatter.string(from: article.logicalDatePublished) + // When in landscape the context menu preview will force this controller into a tiny + // view space. If it is documented anywhere what that is, I haven't found it. This + // set of magic numbers is what I worked out by testing a variety of phones. + + let width: CGFloat + let heightPadding: CGFloat + if view.bounds.width > view.bounds.height { + width = 260 + heightPadding = 16 + view.widthAnchor.constraint(equalToConstant: width).isActive = true + } else { + width = view.bounds.width + heightPadding = 8 + } + view.setNeedsLayout() view.layoutIfNeeded() - preferredContentSize = CGSize(width: view.bounds.width, height: dateTimeLabel.frame.maxY + 8) + preferredContentSize = CGSize(width: width, height: dateTimeLabel.frame.maxY + heightPadding) } }