繁体   English   中英

UITableViewCell不显示背景色

[英]UITableViewCell not showing background color

我直接使用下面的代码从xib加载单元格,但问题是,即使我在xib中进行了设置,该单元格的背景色也未显示,我也通过代码对其进行了设置。 有什么可以指导我解决这个问题的。

我想知道为什么它没有显示在xib中设置的背景颜色

    static NSString *cellIdentifier = @"GameCell123";

UITableViewCell *cell = [tableViewTemp dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) 
{
    NSArray *array=[[NSBundle mainBundle] loadNibNamed:@"GameCell" owner:self options:nil];
    if (array !=nil && [array count]>0) 
    {
        cell=[array objectAtIndex:0];
    }
    [cell setAccessoryView:[cell viewWithTag:3]];
    [(UIButton *)[cell viewWithTag:assessoryButtonCellSubviewTag] addTarget:self action:@selector(teamsAccessoryButtonTap:event:) forControlEvents:UIControlEventTouchUpInside];

    cell.backgroundColor=[UIColor blueColor];
    //cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier] autorelease];
    // seting teams button as accessory view; 
}

如雕刻所示,在willDisplayCell委托方法中更改背景颜色:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell.backgroundColor = [UIColor blueColor];  
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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