ios – 具有非有限位置的子层[inf inf]

ios – 具有非有限位置的子层[inf inf],第1张

概述我正在使用Objective-C编写的第三个 CocoaPods库来截取UITextView的截图.对于iOS 8来说没关系,但是在我更改了iOS 9和 Swift 2的语法后,它会抛出一个错误: Terminating app due to uncaught exception ‘CALayerInvalidGeometry’, reason: ‘sublayer with non-finite 我正在使用Objective-C编写的第三个 CocoaPods库来截取UITextVIEw的截图.对于iOS 8来说没关系,但是在我更改了iOS 9和 Swift 2的语法后,它会抛出一个错误:

Terminating app due to uncaught exception ‘CALayerInvalIDGeometry’,reason: ‘sublayer with non-finite position [inf inf]’

这是来自图书馆的代码:

- (UIImage *)screenshotForCropPingRect:(CGRect)cropPingRect{    UIGraphicsBeginImageContextWithOptions(cropPingRect.size,NO,[UIScreen mainScreen].scale);    // Create a graphics context and translate it the vIEw we want to crop so    // that even in grabbing (0,0),that origin point Now represents the actual    // cropPing origin desired:    CGContextRef context = UIGraphicsGetCurrentContext();    if (context == NulL) return nil;    NSLog(@"hiii :%f",cropPingRect.size.wIDth);    CGContextTranslateCTM(context,-cropPingRect.origin.x,-cropPingRect.origin.y);    [self layoutIfNeeded];    [self.layer renderInContext:context];    UIImage *screenshotimage = UIGraphicsGetimageFromCurrentimageContext();    UIGraphicsEndImageContext();    return screenshotimage;}

问题是这一行:

[self.layer renderInContext:context];

我意识到这是因为我试图拍摄包含UIScrollVIEw的UIVIEw的快照.如果我删除UIScrollVIEw子视图,则错误消失.

那么这是什么意思?

sublayer with non-finite position [inf inf]

任何人都有同样的问题,你是如何解决的?

解决方法 以下是我解决这个问题的方法:

关注这篇文章

https://github.com/facebook/ios-snapshot-test-case/issues/112

错误来自我使用的库,因此搜索所有文件并查找

CGRectNull

并将它们全部改为

CGRectZero

这解决了这个问题.

总结

以上是内存溢出为你收集整理的ios – 具有非有限位置的子层[inf inf]全部内容,希望文章能够帮你解决ios – 具有非有限位置的子层[inf inf]所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1115012.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存