I've got a UIView that I'm adding to a cell's content view in a particular section (Section 1 specifically), as shown below:
[cell.contentView addSubview:self.overallCommentViewContainer];
When I quickly scroll up/down - the UIView appears in Section 0 - even though I never added the UIView to any of the cell's in Section 0.
Here's a detailed look at my cellForRowAtIndexPath
method:
- (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;
}