自定义绘制UITableViewCell

Xet*_*ius 3 iphone cocoa-touch uitableview

我正在尝试创建一个UITableViewCell,它覆盖了内容的完整绘图.我已经覆盖了正在调用的drawRect,但它仍然绘制了默认内容.

如何让它停止绘制默认内容,如何用自己的渲染替换它?

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    DLog (@"Overloaded TableCell initWithStyle");
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {

    }
    return self;
}

- (void)drawRect:(CGRect)rect {
    DLog (@"TableCell::drawRect");

    // expecting it to draw nothing
}
Run Code Online (Sandbox Code Playgroud)

Pra*_*ogg 9

Loren Brichter(Tweetie的作者)在iTunes U Stanford iPhone编程课程讲座中谈到了这一点.他说通过子类化UITableViewCell并直接绘制每个单元格的内容,他获得了很好的滚动性能结果,并在他关于这个主题的博客文章中给出了一个代码示例.

他还指出,苹果在其中一个代码示例中添加了类似的示例.

  • 我没有看到这个回答是如何回答的问题:'我已经覆盖了drawRect,它被调用,但它仍然会绘制默认内容.' (4认同)