iphone - CGContextClip空路径错误(自定义UINavigationBar背景)

标签 iphone ios4 background uinavigationbar

收到错误“:doClip:空路径。”上

CGContextClip(ctx);

当使用 Ahmet Ardal 的代码进行 UINavigationBar 自定义背景的自定义时。

理想情况下,我想解决此错误 - 它会阻止 Apple 的批准吗?

我的理解是它定义了要绘制的剪切区域。我已经将导航栏图形设置为正确的大小,因此理论上它们不需要被剪切。

因此注释掉了有问题的行。一切似乎都很棒,但担心它可能会产生我不知道的影响

下面是经过调整的代码,因此如果您有更深的横向栏(例如其中有分段控件),它就可以工作

- (void) drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
    if ([self isMemberOfClass:[UINavigationBar class]] == NO) {
        return;
    }

    //NSLog(@"NAV HEIGHT IS %f %f",self.frame.size.height, self.frame.size.width);  

    UIImage *image = nil; 

    if (self.frame.size.width > 320) {
        if (self.frame.size.height > 32) {
            // Deep NavBar
            image = [UINavigationBar bgImageLandscapeDeep];
        } else {
            image = [UINavigationBar bgImageLandscape];
        }
    } else {
        image = [UINavigationBar bgImagePortrait];
    }


    NSLog(@"CGContextClip produces <Error>: doClip: empty path. Path is %@",ctx);
    //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);
}

最佳答案

我继承了一个带有 drawLayer:inContext: 方法的应用程序,该方法调用 CGContextClip(...) 并生成“: doClip: 空路径”。消息。

将其提交给商店没有任何问题;我非常有信心该错误是无害的。

根据苹果的文档:

Parameters
c
A graphics context that contains a path. If the context does not have a current path, the function does nothing.

http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html

如果您确实想阻止记录错误,您可能应该在调用CGContextClip(...)之前检查上下文:

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

关于iphone - CGContextClip空路径错误(自定义UINavigationBar背景),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5982180/

相关文章:

iphone - iOS滑动/滑动菜单,如Facebook应用程序

ios - 如何实现像iPhone 4视频播放器框架滚动一样的滚动

html - 悬停按钮图像不适合所有菜单?

iphone - Xcode 4 中没有 gcc 4.2 编译器选项?

iphone - iPhone 中的内置图像是否有记录?是否有它们的名称列表?

iphone - 应用程序加载器中的托管内容包是什么?

objective-c - 我的应用调用 scrollViewDidScroll 19 次

concurrency - 异步 NSURLConnection,并发 NSOperation,什么时候使用 NSRunLoop?

html - CSS 内容/侧边栏跟随背景

css - 带有箭头的对话框背景图像使用相同的背景