【发布时间】:2012-11-01 19:10:29
【问题描述】:
我在尝试创建 UIImageView 时出错。 看这段代码:
UIImage* backgroundPanel = [[UIImage imageNamed:@"loginPanelBackground.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(90, 0, 149, 416)];
self.connexionBackgroundImgView = [[UIImageView alloc] initWithImage:backgroundPanel];
self.connexionBackgroundImgView.frame = CGRectMake(0, 0, 416, 390); // THIS LINE PROVOC THE INVALID CONTEXT
[self.connexionView insertSubview:self.connexionBackgroundImgView aboveSubview:self.connexionToCreationCompteView];
它在日志中抛出这个错误:
<Error>: CGContextSaveGState: invalid context 0x0
<Error>: CGContextSetBlendMode: invalid context 0x0
<Error>: CGContextSetAlpha: invalid context 0x0
<Error>: CGContextTranslateCTM: invalid context 0x0
<Error>: CGContextScaleCTM: invalid context 0x0
<Error>: CGContextGetCTM: invalid context 0x0
<Error>: CGContextSaveGState: invalid context 0x0
<Error>: CGContextClipToRect: invalid context 0x0
<Error>: CGContextDrawTiledImage: invalid context 0x0
<Error>: CGContextRestoreGState: invalid context 0x0
<Error>: CGContextGetCTM: invalid context 0x0
<Error>: CGContextSaveGState: invalid context 0x0
<Error>: CGContextClipToRect: invalid context 0x0
<Error>: CGContextDrawTiledImage: invalid context 0x0
<Error>: CGContextRestoreGState: invalid context 0x0
<Error>: CGContextGetCTM: invalid context 0x0
<Error>: CGContextSaveGState: invalid context 0x0
<Error>: CGContextClipToRect: invalid context 0x0
<Error>: CGContextDrawTiledImage: invalid context 0x0
<Error>: CGContextRestoreGState: invalid context 0x0
<Error>: CGContextRestoreGState: invalid context 0x0
我只在 iPad 上遇到过这个错误,在模拟器上没有,我不明白..:/
【问题讨论】:
-
您是否使用任何自定义绘图代码?喜欢使用 CGContext 等等?
-
也尝试改变 self.connexionBackgroundImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 416, 390)]; [self.connexionBackgroundImgView setImage:backgroundPanel];其实应该不会有太大区别。不过你还是可以试试的。
-
您是否使用任何自定义绘图?在某处实现 CGContext?
-
感谢 eliajf,您能否发表您的评论作为答案。那我就认了吧!
标签: ios uiimageview uiimage cgcontext