UIScrollView CALayer position contains NaN

817 views Asked by At

While trying to zoom in my UIScrollView I'm getting the following exception..

    2015-06-17 12:42:24.959 GeoSwift[7389:1579038] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'
*** First throw call stack:
(0x183e482d8 0x1953bc0e4 0x183e48218 0x1881c4ac4 0x1881c4a1c 0x188a23c74 0x188a1f0dc 0x1888b8720 0x188d294fc 0x18887c484 0x18887a830 0x1888b6898 0x1888b5f50 0x18888918c 0x188b2a324 0x1888876a0 0x183e00240 0x183dff4e4 0x183dfd594 0x183d292d4 0x18d4076fc 0x1888eefac 0x1000f2f38 0x195a3aa08)
libc++abi.dylib: terminating with uncaught exception of type NSException

That is the problem here? How to solve it?

1

There are 1 answers

0
Eddie On BEST ANSWER

I've just got quite the same problem and solved this.

Reason (in my case):

The scrollView I used contains an image loaded from the internet, using UIImageView+WebCache (SDWebImage framework). So, before the image is fully loaded, when I try zooming the scroll view, it crashed with the log just like you. I haven't detected the exact reason why, but it's the main reason. Therefore.....

Solution:

I just disable the zoom when the image is not loaded to the scrollView.

self.scrollableImageView.minimumZoomScale = 1;
self.scrollableImageView.maximumZoomScale = 1;

[self.mainImageView sd_setImageWithURL:urlImage placeholderImage:imageHolder options:SDWebImageHighPriority completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
            // re-enable zoom
            [self updateZoomScale];
        }];

Hope this help.