From ace681c2b37a9504dbf852cd529d67cadc4857f5 Mon Sep 17 00:00:00 2001 From: thomasdao Date: Tue, 4 Feb 2020 16:37:53 +0700 Subject: [PATCH] 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" --- Sources/ImageViewerController.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/ImageViewerController.swift b/Sources/ImageViewerController.swift index 370bfa6..e72b113 100644 --- a/Sources/ImageViewerController.swift +++ b/Sources/ImageViewerController.swift @@ -222,6 +222,10 @@ class ImageViewerController:UIViewController, UIGestureRecognizerDelegate { extension ImageViewerController { func updateMinMaxZoomScaleForSize(_ size: CGSize) { + if imageView.bounds.width == 0 || imageView.bounds.height == 0 { + return + } + let minScale = min( size.width/imageView.bounds.width, size.height/imageView.bounds.height)