【问题标题】:CGContextDrawPath: invalid context 0x0CGContextDrawPath:无效的上下文 0x0
【发布时间】:2013-02-05 14:29:35
【问题描述】:

我有这段代码,我认为是这里的问题:

CGContextRef context =  CGBitmapContextCreate(nil,
                                              routeView.frame.size.width,
                                              routeView.frame.size.height,
                                              8,
                                              4 * routeView.frame.size.width,
                                              CGColorSpaceCreateDeviceRGB(),
                                              kCGImageAlphaPremultipliedLast);

CGContextSetStrokeColorWithColor(context, lineColor.CGColor);
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1.0);
CGContextSetLineWidth(context, 1.0);

来自:https://github.com/kadirpekel/MapWithRoutes/tree/master/Classes

这实际上是在对该项目进行任何更改,然后我尝试将某些内容导入我的代码并且不起作用,我收到此错误:

Feb  5 14:16:17 alejandro.upes.itccanarias.org GPSTestMap[2878] <Error>: CGContextSetStrokeColorWithColor: invalid context 0x0
Feb  5 14:16:17 alejandro.upes.itccanarias.org GPSTestMap[2878] <Error>: CGContextSetRGBFillColor: invalid context 0x0
Feb  5 14:16:17 alejandro.upes.itccanarias.org GPSTestMap[2878] <Error>: CGContextSetLineWidth: invalid context 0x0
Feb  5 14:16:17 alejandro.upes.itccanarias.org GPSTestMap[2878] <Error>: CGContextDrawPath: invalid context 0x0
Feb  5 14:16:17 alejandro.upes.itccanarias.org GPSTestMap[2878] <Error>: CGBitmapContextCreateImage: invalid context 0x0

【问题讨论】:

  • 确保您的 routeView 已正确初始化并且 CGBitmapContextCreate 函数不返回 nil
  • 好的,这里我有这个来初始化我的 routeView:routeView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, mapView.frame.size.width, mapView.frame.size.height)]; 是的 >.
  • 好的伙计,大声笑,谢谢我今天做白日梦....谢谢

标签: ios xcode cgcontext cgcontextdrawimage


【解决方案1】:

答案是@Sohaib 评论:

Make sure your routeView is initialized properly and CGBitmapContextCreate function doesn't return nil – Sohaib 2013 年 2 月 5 日 14:32

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-30
    • 2012-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多