这个问题已经在这里有一个答案:
- 分配现有CGColor到CGColor财产iPhone模拟器,而不是iOS设备的工作原理。 为什么? 3个回答
我子类的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);
}