iphone - 自定义绘制UITableViewCell

标签 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
}

最佳答案

Loren Brichter(Tweetie 的作者)在一次 iTunes U 斯坦福 iPhone 编程类(class)讲座中谈到了这一点。他说,通过子类化 UITableViewCell 并直接绘制每个单元格的内容,他获得了很好的滚动性能结果,他在 his blog post on the subject 中给出了一个代码示例。 .

他还指出,苹果已添加 a similar example在他们的代码示例之一中。

关于iphone - 自定义绘制UITableViewCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1106658/

相关文章:

iphone - 使用 UIViewAnimationTransitionFlipFromRight 翻转时使 UIView 变暗

ios - 使用 PresentModalViewController 更改 View 时出现 EXC_BAD_ACCESS 错误

ios - 如何检测 iPhone 5c 的颜色?

iphone - UITableView 自定义单元格无法流畅滚动,因为数据库阻塞了我的主线程

ios - 不要为已经出现的 UITableView 单元格设置动画

ios - UIPageViewController 不改变页面

iphone - 我们可以在 xcode 中将 iOS 原生应用程序转换为 Web 应用程序吗

具有单例属性的 iPhone 内存管理

iphone - 如何禁用 rightBarButtonItem

ios - 我可以为 iOS 应用程序和网站使用一个解析数据库吗? - 使用 swift