2010-06-11 21 views
3

可可給出了錯誤:可可給錯誤:<Error>:doClip:空路徑

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

但是我沒有這個功能,隨時隨地在我的代碼(不能由框架/項目搜索找到)..似乎很多人抱怨這個,因爲它進入控制檯日誌,但找不到任何原因導致它在程序級別上的原因。

有什麼想法是什麼問題?

回答

3

用類轉儲和納米,我發現它是CoreGraphics(Quartz 2D)中的函數。它沒有在頭文件中聲明,所以它是一個私有函數。

在調試器中中斷doClip,然後向下移動堆棧並查看當時是否有任何代碼正在繪製。如果是這樣,你可能試圖剪輯到一個空的路徑。如果您正在使用第三方框架,您應該向作者提交一個錯誤。

如果你沒有調用它(也不應該),並且第三方框架沒有牽連,那麼它可能是Apple框架中的一個bug。你應該report it to Apple

+0

不打破doClip ...我輸錯了嗎? http://i259.photobucket.com/albums/hh299/PirateOrion/Screenshot2010-06-11at122913PM.png – BadPirate 2010-06-11 19:31:34

+0

你做得對,但看看複選框:斷點沒有綁定。嘗試鏈接ApplicationServices;如果這沒有幫助,我的猜測是該函數是「靜態」的,所以不能在斷點中命名。 – 2010-06-12 00:29:10

+2

我發現如果你在CGPostError中斷,你可以得到要觸發的斷點。 – memmons 2011-03-21 15:10:52

1

我在繪製上下文並試圖剪輯它之前就已經看到過這個錯誤。你在做任何這樣的背景畫嗎?

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); 
+0

沒有。這是降低的東西。但我害怕我已經移動:) – BadPirate 2011-03-10 22:35:21

1

當我執行以下方法來設置特定於橫向方向的導航欄圖像覆蓋時,我遇到了同樣的問題。擺脫剪輯錯誤我評論出代碼的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 
4

我只檢查,看看是否該路徑中使用是空的:CGContextIsPathEmpty(CGContextRef CTX)

實施例:

if(!CGContextIsPathEmpty(c)) 
    CGContextClip(c);