我是继承UIView并使用它的实例来设置我的UITableViewCell backgroundView和selectedBackedView属性。我在UIView子类的drawRect方法中收到EXC_BAD_ACCESS错误。CGContextRef - EXC_BAD_ACCESS错误
if(nil == cell){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
cell.backgroundView = [[CCViewBackground alloc]init];
cell.selectedBackgroundView = [[CCViewBackground alloc]init];
}
UIView子类CCBackgroundView -drawRect:
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorRef redColor =
[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0].CGColor;
CGContextSetFillColorWithColor(context, redColor); //Receiving EXC_BAD_ACCESS here
CGContextFillRect(context, self.bounds);
}
你能为你的应用启用NSZombie并分享接收的原因EXC_BAD_ACCESS –
这是现在NSZombie启用的错误信息 - *** - [Not A Type retain]:发送到释放实例的消息0x109b50 – Michael