在尝试了几种不同的解决方案之后,修复了,我终于找到了一个解决方案。我所需要做的就是在backgroundColor方法中将单元格willDisplayCell设置为清除:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
[cell setBackgroundColor:[UIColor clearColor]];我的UITableview有一个背景图像(照片),表格视图中的单元格有一个半透明的背景。
当我第一次显示UITableView时,单元格显示的不是透明的。但只要我把一个单元格从屏幕上滚动回来,并在显示半透明背景的单元格上回滚。
有没有人有任何线索,为什么它不能正确地显示,直到单元格是在屏幕外滚动?见附图。第一种是在加载后立即显示表视图。第二张图片显示了在屏幕外滚动前几个单元格后的样子,然后又重新打开了。


下面是我用来设置单元格的代码。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellPhotoIdentifier = @"PhotoDescriptionCell";
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellPhotoIdentifier] autorelease];
// Configure the cell...
cell.textLabel.text = [NSString stringWithFormat:@"Photo description %i", indexPath.row];
cell.textLabel.textColor = [UIColor whiteColor];
cell.opaque = NO;
cell.contentView.backgroundColor = [UIColor blackColor];
cell.contentView.opaque = NO;
cell.contentView.alpha = 0.7;
cell.textLabel.backgroundColor = [UIColor clearColor];
return cell;
}我使用的是XCode 4和IOSSDK4.3
发布于 2011-08-22 08:04:29
在重新阅读了@progrmr给出的链接的答案之后,我又试了一次,并设法让它开始工作。
我需要在willDisplayCell方法中将单元格背景颜色设置为清除
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath [细胞背景颜色:UIColor clearColor];
发布于 2011-08-19 14:51:09
可能的情况是,您首先加载单元格,然后将其设置为已加载的透明单元格。然后,一旦你滚动他们离开屏幕和回到,他们是透明的,因为你已经强迫他们重新加载与正确的设置。
您可以修复此buy,更改Interface Builder中的单元格属性,使单元格从一开始就透明,或者在配置单元格后,需要添加强制单元格重新加载自身的代码。让我试着找,因为我不知道我的头顶。
此问题将帮助您计算出单元格重新加载:Reloading only one UITableViewCell on a UITableview。
https://stackoverflow.com/questions/7123118
复制相似问题