title: Custom drawing UIView inside of UITableViewCell
body: <p>I'm creating a UIView (actually is one of the subviews in the contentView) which draw a stat. </p>
  
  <p>This view is set in each cell of a UITableview.</p>
  
  <p>I configure the cell, in:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      NSString *cellConstant = @"constant";
  
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellConstant forIndexPath:indexPath];
  
      SCHGraphicView *statView = (SCHGraphicView *)[cell viewWithTag:TAG_STAT_GRAPH];
      [statView setStatValues:[self.listOfListWithValues objectAtIndex:indexPath.row] andBase:10 andColorBar:[UIColor whiteColor]];    
  
      return cell;
  }
  </code></pre>
  
  <p>This is the drawRect method, which now in test mode I'm drawing just one value.</p>
  
  <pre><code>- (void)drawRect:(CGRect)rect
  {
       CGFloat heightCalculate = ([(NSNumber *)[self.statValues objectAtIndex:1]intValue] *self.frame.size.height) / self.base;
      //We create the path
      UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(0,self.frame.size.height - heightCalculate, self.frame.size.width, heightCalculate)];
      path.lineWidth = 0;
      [self.barColor setFill];
  
      CGContextRef context = UIGraphicsGetCurrentContext();
  
      //We saved the context
      CGContextSaveGState(context);
  
  
  
      [path fill];
      //Restore the contex
      CGContextRestoreGState(context);
  }
  </code></pre>
  
  <p>Althought I modify the stat values every time in <code>cellForRowAtIndexPath:</code>, these values don't call to [UIView setNeedDisplay] so I don't redraw it each time due to the stat never change in each cell but is different stat if you compare stats between cells.</p>
  
  <p>The problem is when I scroll and I come back to the first cell, this doesn't contains the stat which initially was drawn.</p>
  
  <p>The only way I've achieved that is redraw every time the stat in <code>cellForRowAtIndexPath</code>
  but I thought a preview was saved in the first time when the view was drawn and this was used to improve the performance and if you call to [UIView setNeedDisplay] the view is redraw again.</p>
  
  <p>Any idea?</p>
  
  <p>Thanks so much</p>