关于这个可怕的问题,我已经阅读了尽可能多的搜索结果,不幸的是,每个搜索结果似乎都集中在一个特定的函数调用上。

我的问题是,我从多个函数得到相同的错误,我猜是从我使用的函数回调的。

更糟糕的是,实际的代码是在另一个项目中导入的自定义私有框架中,因此,调试不是那么简单吗?

有人能告诉我正确的方向吗?我有一种感觉,我正在错误地调用某些方法或与坏的上下文,但xcode的输出在这一点上不是很有帮助。

: CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. : CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. : CGContextSetFlatness: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. : CGContextAddPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. : CGContextDrawPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. : CGContextRestoreGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. : CGContextGetBlendMode: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

当呈现自定义视图或其继承的类之一时,可能会发生这些错误。这时它们会生成多次,直到键盘不再提供任何输入。触摸事件仍然被注册,但是系统变慢,最终可能导致未分配对象错误。

编辑#1:我确实可以访问正在导入的框架,但我没有看到导致问题的类中有任何奇怪的东西。

编辑#2:我刚刚收到一封电子邮件,iOS 7.1已经发布给开发者了。我很好奇这种情况是否会消失,或者变得更糟,或者是否能得到解决。


当前回答

这有点俗气,但对我很管用。

我在UITableViewCell的init中设置了UIImageView,给它一个大小和约束。

然后在我的视图控制器的cellForRowAtIndexPath中我这样做:

let img = PFImageView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
img.setImage(withFile: nil, defaultText: message.senderUsername)
cell.profileImageView?.image = img.image

这避免了错误,在函数下面,我为UIImageView设置了实际图像。上面的代码是一个很好的默认值

其他回答

如果在使用UIBezierPath并为描边或填充设置颜色时发生错误,请将设置的颜色代码放在drawRect函数中而不是其他地方。

我也有同样的问题。 在我的项目中,我尝试创建一个文本字段,并将其添加到我的pdf文件。 旧的代码:

- (void) drawInContext:(CGContextRef)context {
    //Otherwise we're upside-down
    CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0));

    CGContextSetTextDrawingMode(context, kCGTextFill); // This is the default
    [[UIColor blackColor] setFill]; // ***This is the problem ***

    CGFloat x = self.rect.origin.x;
    CGFloat y = self.rect.origin.y + self.font.pointSize;
    [self.text drawAtPoint:CGPointMake(x, y)
            withAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Arial" size:12]}];
}

解决此问题后,代码更改为:

old:[[UIColor blackColor] setFill]; 

new:CGContextSetFillColorWithColor(context, [[UIColor blackColor] CGColor]);

我发现解决方案在UIColor SetFill不工作。 谢谢那个帮手。

我得到了代码错误

UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:pointA];
[path addLineToPoint:pointB];
[path addLineToPoint:pointC];
[[UIColor colorWithHexString:@"EFEFEF"] set];
[path fill];
[path closePath];

CAShapeLayer *triangle = [CAShapeLayer layer];
triangle.fillColor = [UIColor colorWithHexString:@"EFEFEF"].CGColor;
triangle.path = path.CGPath;

return triangle;

并在删除代码后

[[UIColor colorWithHexString:@"EFEFEF"] set];
[path fill];

世界变得寂静

从模拟器卸载应用程序,并再次运行

我有这个问题与一个简单的UITextField(键盘不显示和许多不同的无效上下文错误消息在控制台)。 我只是通过查找SO上的另一个问题找到了一个解决方案:无法找到CFBundle CertUIFramework.axbundle的可执行文件

只做:

点击iOS模拟器>重置内容和设置…然后再跑。

问题不应该再存在了