UIScrollView CALayer 位置包含 NaN
UIScrollView CALayer position contains NaN
在尝试放大我的 UIScrollView 时出现以下异常..
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
这就是问题所在?如何解决?
我刚刚遇到了完全相同的问题并解决了这个问题。
原因(以我为例):
我使用的scrollView包含一张从网上加载的图片,使用UIImageView+WebCache(SDWebImage框架)。因此,在图像完全加载之前,当我尝试缩放滚动视图时,它和您一样崩溃了。我还没有发现确切的原因,但这是主要原因。因此.....
解法:
我只是在图像未加载到 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];
}];
希望对您有所帮助。
在尝试放大我的 UIScrollView 时出现以下异常..
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
这就是问题所在?如何解决?
我刚刚遇到了完全相同的问题并解决了这个问题。
原因(以我为例):
我使用的scrollView包含一张从网上加载的图片,使用UIImageView+WebCache(SDWebImage框架)。因此,在图像完全加载之前,当我尝试缩放滚动视图时,它和您一样崩溃了。我还没有发现确切的原因,但这是主要原因。因此.....
解法:
我只是在图像未加载到 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];
}];
希望对您有所帮助。