1

これは明らかかもしれませんが、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;
}

私が得るものはこれです:

表ビューのセルの背景が黒

セルの背景は、クリックしてテキストを表示するまで、デフォルトで黒です。何か不足していますか?

4

2 に答える 2

6

ラベルの背景とセルの背景を設定する必要があります。

cell.textLabel.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
于 2012-06-18T14:53:32.887 に答える
1

使用する :

cell.contentView.backgroundColor=[UIColor clearColor];

それ以外の:

cell.backgroundColor=[UIColor clearColor];
于 2012-06-18T14:50:24.760 に答える