UITableViewCell黑色背景

Mal*_*loc 1 uitableview ios

我知道这可能很明显,但我没有将背景设置为IB中的任何颜色.我的代码UITableView是这样的:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"Cell Identifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];

    if(!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
    }

    cell.textLabel.text = [_listeDesChapitres objectAtIndex:indexPath.row];
    cell.backgroundColor = [UIColor clearColor];

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

我得到的是这个:

表视图单元格具有黑色背景

默认情况下,单元格背景为黑色,直到我单击它以查看其文本.我错过了什么吗?

Ant*_* MG 6

您需要设置标签的背景和单元格的背景:

cell.textLabel.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
Run Code Online (Sandbox Code Playgroud)