gpt4 book ai didi

iOS 8 崩溃 - renderInContext :UIGraphicsGetCurrentContext()

转载 作者:可可西里 更新时间:2023-11-01 04:43:50 31 4
gpt4 key购买 nike

在 iOS 8 之前,我对此没有问题,现在,是的。

日志:

Assertion failed: (CGFloatIsValid(x) && CGFloatIsValid(y)), function void CGPathMoveToPoint(CGMutablePathRef, const CGAffineTransform *, CGFloat, CGFloat), file Paths/CGPath.cc, line 254.

这是我的代码:

UIImage* image = nil;

CGSize imageSize = CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height);

UIGraphicsBeginImageContextWithOptions(imageSize, NO , 0.0f);

[self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; // <- ERROR

image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

我的目的是将 View 转换为图像。

最佳答案

检查您正在绘制的内容中是否存在空矩形,无论是 View 的边界还是图层的内容矩形。我注意到 iOS 8 上的断言失败,在此之前,空矩形会被静默忽略。

我添加了一些...

if (!CGRectIsEmpty(bounds)) {
}

...我绘图中的条件。

关于iOS 8 崩溃 - renderInContext :UIGraphicsGetCurrentContext(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27193493/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com