title: iPhone - How to use ABTableViewCell?
body: <p>I'm working on a <code>UITableView</code> whose cells contain an <code>UIImageView</code> subclass which gets data from a URL and cache images to the iphone disk.</p>
  
  <p>Problem is, event with cached images the scrolling tends to be stuttering. So I searched a bit and found <code>ABTableViewCell</code> ( github.com/enormego/ABTableViewCell ) which is supposed to dramatically improve scrolling smoothness.</p>
  
  <p>But, even with the example provided ( blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview ) I don't really get what I am supposed to do.</p>
  
  <p>I tried to do this: I created a class which inherits <code>ABTableViewCell</code>,  added some UILabels and the UIImageView as class properties, and implemented methods this way: allocate and initialize subviews (labels, image) in the <code>initialize</code> class method, storing them in static pointers, and then set class properties in <code>- (void)drawContentView:(CGRect)r highlighted:(BOOL)highlighted</code> along with background color setting shown in example. Here's the result:</p>
  
  <pre><code>static AsyncUIImageView* image = nil; // A subclass using ASIHTTPRequest for image loading
  static UILabel*       label1 = nil;
  static UILabel*       label2 = nil;
  
  + (void)initialize {
      if (self == [ResultTableViewCell class]) {
          image = [[[AsyncUIImageView alloc] initWithFrame:CGRectMake(0, 0, 80, 60)] retain];
  
          label1 = [[[UILabel alloc] initWithFrame:CGRectMake(90, 5, 150, 30)] retain];
          label1.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
          label1.textColor = [UIColor purpleColor];
          label1.backgroundColor = [UIColor clearColor];
  
          label2 = [[[UILabel alloc] initWithFrame:CGRectMake(180, 8, 100, 25)] retain];
          label2.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.0];
          label2.textColor = [UIColor grayColor];
          label2.backgroundColor = [UIColor clearColor];
      }
  }
  
  - (void)drawContentView:(CGRect)r highlighted:(BOOL)highlighted {
      if (self.imageView == nil) {
          self.imageView = image;
          [self addSubview:image];
  
          self.firstLabel = label1;
          [self addSubview:label1];
  
          self.secondLabel = label2;
          [self addSubview:label2];
      }
  
  CGContextRef context = UIGraphicsGetCurrentContext();
  
      UIColor *backgroundColor = [UIColor whiteColor];
      UIColor *textColor = [UIColor blackColor];
  
      if (self.selected || self.highlighted) {
          backgroundColor = [UIColor clearColor];
          textColor = [UIColor whiteColor];
      }
  
      [backgroundColor set];
      [textColor set];
      CGContextFillRect(context, r);      
  }
  </code></pre>
  
  <p>This gives me completely black cells, sometimes one has text and image set with correct colors, but its content changes as I scroll down.
  Obviously I did not understand what I am supposed to do in <code>drawContentView</code>.</p>
  
  <p>Could someone explain its purpose?</p>