【问题标题】:Invalid Context 0x0 when dismissing a UIImageView关闭 UIImageView 时上下文 0x0 无效
【发布时间】:2013-11-18 01:43:02
【问题描述】:

当我尝试用

解散UIImageView时
- (void)handleGesture:(UIGestureRecognizer *)gestureRecognizer {
    CGPoint p = [gestureRecognizer locationInView:self.view];
    if (CGRectContainsPoint(_tutorial.frame, p)) {
        _tutorial.hidden = YES;

        _transButton.enabled = YES;
        _transButtonEng.enabled = YES;
        _infoButton.enabled = YES;
        _textfield.enabled = YES;
    }
    else {
        NSLog(@"HOW IS THIS EVEN POSSIBLE?!?!?"); //The CGRect is the whole screen
    }
}

我收到此错误消息:

MacBook-Pro.local APP_NAME[97086]:CGContextSetFillColorWithColor:无效上下文 0x0。这是一个严重的错误。此应用程序或它使用的库正在使用无效的上下文,从而导致系统稳定性和可靠性的整体下降。此通知是出于礼貌:请解决此问题。这将成为即将到来的更新中的致命错误。

它还重复相同的消息,CGContextSetFillColorWithColor: 替换为:

CGContextSetStrokeColorWithColor:
CGContextSaveGState:
CGContextSetFlatness:
CGContextAddPath:
CGContextDrawPath:
CGContextRestoreGState:
CGContextSaveGState:
CGContextSetFlatness:
CGContextAddPath:
CGContextDrawPath:
CGContextRestoreGState:
CGContextSetFillColorWithColor:
CGContextSetStrokeColorWithColor:
CGContextSetFillColorWithColor:
CGContextSetStrokeColorWithColor:
CGContextGetBlendMode:
CGContextSetBlendMode:
CGContextFillRects:
CGContextSetBlendMode:
CGContextSetFillColorWithColor:
CGContextSetStrokeColorWithColor:
CGContextGetBlendMode:
CGContextSetBlendMode:
CGContextFillRects:
CGContextSetBlendMode:
CGContextSetFillColorWithColor:
CGContextSetStrokeColorWithColor:
CGContextGetBlendMode:
CGContextSetBlendMode:
CGContextFillRects:
CGContextSetBlendMode:

我使用的是最新版本的 Xcode 5 和 iOS 7.0.3。

我将如何解决这些错误?

【问题讨论】:

  • 在您复制到问题的代码中,您还应该包含调用“CGContextSetFillColorWithColor”的方法/函数。
  • @MichaelDautermann 我不会在任何地方称呼这些;我使用界面生成器
  • 我不知道这是否相关,但有已知的 iOS 7 错误会导致这种行为:stackoverflow.com/questions/19599266/…
  • 我见过这些,但我想知道是否有解决 UIGestureRecognizer/UIImageView 导致错误的方法

标签: ios cocoa-touch uiimageview


【解决方案1】:

隐藏_tutorial imageView 后,您应该移除手势识别器(通过 UIGestureRecgonizer 的 "removeTarget: action:" API,这样您就不会在隐藏视图上调用“CGRectContainsPoint”,而谁知道帧值是什么.

【讨论】:

  • 你能举个例子吗?我在阅读大多数类型的 API 文档时遇到了很多麻烦。
猜你喜欢
  • 2013-10-30
  • 2012-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多