【发布时间】:2012-09-02 16:12:14
【问题描述】:
我正在继承 UIView 并使用它的实例来设置我的 UITableViewCell backgroundView 和 selectedBackedView 属性。我在 UIView 子类的 drawRect 方法中收到 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]: message sent to deallocated instance 0x109b50
标签: iphone ios cocoa-touch core-graphics