Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
426 views
in Technique[技术] by (71.8m points)

iphone - Custom draw a UITableViewCell

I am trying to create a UITableViewCell which overrides the complete drawing of the contents. I have overridden drawRect, which is being called, but it still draws the default contents.

How do I get it to stop drawing the default contents and how do I replace it with my own rendering?

- (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
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Loren Brichter (author of Tweetie) talked about this in one of the iTunes U Stanford iPhone Programming course lectures. He said that he had gotten great scrolling performance results by subclassing UITableViewCell and drawing the contents of each cell directly and he gives a code example in his blog post on the subject.

He also notes that apple has added a similar example in one of their code examples.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...