【问题标题】:UIScrollView CALayer position contains NaNUIScrollView CALayer 位置包含 NaN
【发布时间】:2015-06-17 10:45:07
【问题描述】:

在尝试放大我的 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

这就是问题所在?如何解决?

【问题讨论】:

    标签: uiscrollview nan


    【解决方案1】:

    我刚刚遇到了同样的问题并解决了这个问题。

    原因(就我而言):

    我使用的滚动视图包含从互联网加载的图像,使用 UIImageView+WebCache(SDWebImage 框架)。因此,在图像完全加载之前,当我尝试缩放滚动视图时,它会像您一样与日志一起崩溃。我还没有发现确切的原因,但这是主要原因。所以.....

    解决方案:

    我只是在图像未加载到滚动视图时禁用缩放。

    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];
            }];
    

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2019-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多