diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift index c28f1433..4c810c42 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift @@ -43,6 +43,7 @@ class GalleryItemViewController: UIViewController { private(set) var controlsVisible: Bool = true private(set) var scrollAndZoomEnabled = true + private var scrollViewSizeForLastZoomScaleUpdate: CGSize? override var prefersHomeIndicatorAutoHidden: Bool { return !controlsVisible } @@ -219,6 +220,12 @@ class GalleryItemViewController: UIViewController { override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() + // When the scrollView size changes, make sure the zoom scale is up-to-date since it depends on the scrollView's bounds. + // This might also fix an issue on macOS (Designed for iPad) where the content isn't placed correctly. See #446 + if scrollViewSizeForLastZoomScaleUpdate != scrollView.bounds.size { + scrollViewSizeForLastZoomScaleUpdate = scrollView.bounds.size + updateZoomScale(resetZoom: true) + } centerContent() } @@ -303,6 +310,8 @@ class GalleryItemViewController: UIViewController { } func updateZoomScale(resetZoom: Bool) { + scrollView.contentSize = content.contentSize + guard scrollAndZoomEnabled else { scrollView.maximumZoomScale = 1 scrollView.minimumZoomScale = 1