我创建一个UIView(实际上是在内容查看子视图中的一个),它绘制统计内绘制的UIView。自定义的UITableViewCell
这种观点是在一个UITableView的每个小区设置。
我配置的电池,在:
- (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;
}
这是drawRect方法,它现在处于测试模式我画只是一个值。
- (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);
}
Althought我cellForRowAtIndexPath:
每一次修改的统计值,这些值不来电[UIView的setNeedDisplay]所以我不每次重绘由于统计在每个小区从来没有改变,但不同的是统计如果您比较单元格之间的统计信息。
问题是,当我滚动,我回来第一个单元格,这不包含最初得出的统计。
我实现这一目标的唯一方法是每次重绘cellForRowAtIndexPath
中的统计信息,但我认为预览是在第一次绘制视图时保存的,并且用于提高性能,如果您打电话给[UIView setNeedDisplay]视图再次重绘。
有什么想法?
非常感谢
是的,我做到了,我创造了一个视图。其实是contentView中的子视图之一。感谢您的回答 :) – xarly