iPad:无法在拆分视图中设置自定义单元格的背景颜色

Ank*_*han 6 iphone objective-c ipad

我试图设置自定义单元格的背景颜色,但不显示背景颜色.

 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]];
}
Run Code Online (Sandbox Code Playgroud)

这是因为splitview.

Max*_*Max 13

尝试使用cell.contentView.backgroundColorcell.backgroundView.backgroundColor代替.