【发布时间】:2012-01-04 16:38:09
【问题描述】:
我在这里添加颜色,但它没有反映在单元格中。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.font =[UIFont systemFontOfSize:14];
//cell.textLabel.textColor = theFontColor;//this does not work
//cell.textLabel.textColor = [UIColor whiteColor];//this works
// Configure the cell.
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
编辑
configureCell 覆盖了颜色。抱歉,这是一个真正的菜鸟错误。
【问题讨论】:
-
检查 -configureCell:atIndexPath: 是否没有覆盖您之前设置的颜色。假设设置了字体颜色,所描述的方法应该可以工作。
-
感谢 Warkst 确认它应该可以工作,我跑过去发现虽然设置了字体颜色,但它首先运行了 cellForRowAtIndexPath 并导致了 NSInternalInconsistencyException。
标签: ios objective-c uitableview fonts colors