【发布时间】:2015-02-06 08:09:43
【问题描述】:
我有一个 splitViewController,destinationController 是一个 tableViewController,如果自定义类“MyCell”,我想控制单元格的设计。只有当我拖动 tableView 时才会调用 drawRect :只有在单元格从屏幕上消失并重新出现后才会出现红色背景。你知道为什么吗?
//in viewController.m
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
MyCell*cell = (MyCell*)[tableView dequeueReusableCellWithIdentifier:@"CellDetail"] ;
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
RDV *object = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = [[object valueForKey:@"name"] description];
[cell setNeedsDisplay];
[cell layoutIfNeeded];
}
//in MyCell.m
-(void)drawRect:(CGRect)rect{
[self setBackgroundColor: [UIColor redColor]];
}
【问题讨论】:
标签: ios uisplitviewcontroller drawrect custom-cell