iphone – 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]];
}

这是因为splitview.

解决方法

尝试使用cell.contentView.backgroundColor或cell.backgroundView.backgroundColor.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...