我正在使用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]
任何人都有同样的问题,你是如何解决的?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。