简体   繁体   中英

iPad: unable to set background color of custom cell in split view

I was trying to set the background color of a customized cell but background color is not displayed.

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

Is this because of splitview.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM