UIScrollView的CALayer的位置包含NaN。

3
在尝试缩放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

这是问题所在吗?如何解决它?
1个回答

2
我刚刚遇到了完全相同的问题并解决了它。
原因(在我的情况下):我使用的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];
        }];

希望这能帮助到你。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接