【发布时间】:2009-12-04 17:43:14
【问题描述】:
我有一个 UIView,要添加到特定部分(特别是第 1 部分)的单元格内容视图中,如下所示:
[cell.contentView addSubview:self.overallCommentViewContainer];
当我快速向上/向下滚动时 - UIView 出现在第 0 节中 - 即使我从未将 UIView 添加到第 0 节中的任何单元格中。
下面是我的cellForRowAtIndexPath方法的详细介绍:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *kCustomCellID = @"CustomCellID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCustomCellID];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kCustomCellID] autorelease];
}
// Configure the cell.
switch(indexPath.section) {
case 0:
// other code
break;
case 1:
// add the overall comment view container to the cell
NLog(@"adding the overallCommentViewContainer");
[cell.contentView addSubview:self.overallCommentViewContainer];
NLog(@"creating the row at: Section %d, Row %d", indexPath.section, indexPath.row);
break;
}
return cell;
}
【问题讨论】:
-
我认为这与细胞重用有关。但是,我不确定提供答案
标签: iphone uiview uitableview