创建 UIImageView 时上下文无效 [英] Invalid context when creating UIImageView

查看:20
本文介绍了创建 UIImageView 时上下文无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试创建 UIImageView 时出错.看这段代码:

I have an error when I tried to create a UIImageView. Look at this code :

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];

它在日志中抛出这个错误:

It throws this error in the log :

<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 上遇到过这个错误,在模拟器上没有,我不明白..:/

I had this error only on the iPad, not with the Simulator, I don't understand.. :/

推荐答案

在此处查看答案:如何捕获 UITableView/UIScrollView 的完整内容的 UIImage 并使其在 ios 设备上工作

感谢 eliajf !

Thanks eliajf !

这篇关于创建 UIImageView 时上下文无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆