Skip to content

Commit ace681c

Browse files
committed
Fix scrollView zoom to infinity warning
Check if image view bounds width or height can be zero before setting scroll view zoom, to fix warning "UIScrollView is ignoring an attempt to set zoomScale to a non-finite value: inf"
1 parent 2db4cb4 commit ace681c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/ImageViewerController.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ class ImageViewerController:UIViewController, UIGestureRecognizerDelegate {
222222
extension ImageViewerController {
223223

224224
func updateMinMaxZoomScaleForSize(_ size: CGSize) {
225+
if imageView.bounds.width == 0 || imageView.bounds.height == 0 {
226+
return
227+
}
228+
225229
let minScale = min(
226230
size.width/imageView.bounds.width,
227231
size.height/imageView.bounds.height)

0 commit comments

Comments
 (0)