代码之家  ›  专栏  ›  技术社区  ›  BadPirate

错误:<error>:doClip:空路径

  •  4
  • BadPirate  · 技术社区  · 15 年前

    出现错误:

    Thu Jun 10 19:13:56 myComputer.local myApp[####] <Error>: doClip: empty path.
    

    但是我的代码中没有这个函数(在框架/项目中搜索时找不到)。。。似乎有很多人抱怨这个问题,因为它进入了控制台日志,但找不到任何原因,说明是什么原因导致它在程序层面上。

    你有没有想过问题出在哪里?

    4 回复  |  直到 12 年前
        1
  •  3
  •   Peter Hosey    15 年前

    翻开类dump和nm,我发现它是CoreGraphics(Quartz 2D)中的一个函数。它没有在头文件中声明,所以它是一个私有函数。

    破门而入 doClip 在调试器中,然后向下移动堆栈,查看此时是否有任何代码正在绘制。如果是这样的话,您可能是在尝试剪辑到一个空路径。如果涉及到您正在使用的第三方框架,您应该向其作者提交一个bug。

    如果你不打电话给它(你也不应该打),而且第三方框架也没有牵连进来,那么它可能是苹果框架中的一个bug。你应该 report it to Apple

        2
  •  7
  •   csb    14 年前

    我只想使用以下命令检查路径是否为空:CGContextIsPathEmpty(CGContextRef ctx)

    例子:

    if(!CGContextIsPathEmpty(c))
        CGContextClip(c);
    
        3
  •  1
  •   memmons    14 年前

    CGContextClip(ctx);
    CGContextTranslateCTM(ctx, 0, image.size.height);
    CGContextScaleCTM(ctx, 1.0, -1.0);
    CGContextDrawImage(ctx, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), image.CGImage);
    
        4
  •  1
  •   ninehundreds    14 年前

    当我实现以下方法来设置特定于横向的导航栏图像覆盖时,我也遇到了同样的问题。为了消除剪辑错误,我注释掉了代码的CGContextClip部分,如下所示:

    @implementation UINavigationBar(CustomBackground)
    
    + (UIImage *) bgImagePortrait
    {
        static UIImage *image = nil;
        if (image == nil) {
            image = [[UIImage imageNamed:@"iPhoneHeader_portrait"] retain];
    }
        return image;
    }
    
    + (UIImage *) bgImageLandscape
    {
        static UIImage *image = nil;
        if (image == nil) {
        image = [[UIImage imageNamed:@"iPhoneHeader_landscape"] retain];
        }
        return image;
    }
    
    - (void) drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
    {
        if ([self isMemberOfClass:[UINavigationBar class]] == NO) {
        return;
    }
        UIImage *image = (self.frame.size.width > 320) ?
        [UINavigationBar bgImageLandscape] : [UINavigationBar bgImagePortrait];
        //CGContextClip(ctx); // Causes '<Error>: doClip: empty path.' error when changing views.
        CGContextTranslateCTM(ctx, 0, image.size.height);
        CGContextScaleCTM(ctx, 1.0, -1.0);
        CGContextDrawImage(ctx, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), image.CGImage);
    }
    
    @end