Iphone iPad:无法在拆分视图中设置自定义单元格的背景色
我试图设置自定义单元格的背景色,但未显示背景色Iphone iPad:无法在拆分视图中设置自定义单元格的背景色,iphone,objective-c,ipad,Iphone,Objective C,Ipad,我试图设置自定义单元格的背景色,但未显示背景色 ProjectListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[ProjectListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelea
ProjectListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[ProjectListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
if((indexPath.row%2)!=0)
{
[cell setBackgroundColor:[UIColor redColor]];
}
else
{
[cell setBackgroundColor:[UIColor greenColor]];
}
这是因为splitview。尝试使用
cell.contentView.backgroundColor
或cell.backgroundView.backgroundColor
来代替。是否正确地子类化UITableViewCell类?或者,为什么不尝试将子视图添加到普通的UITableViewCell中呢?效果很好。