views:

38

answers:

1

I'm trying to get rid of a cached UITableView cell. I have two sections. The first cell of the second section has the same "appearance" as the first cell of the first section. With appearance I mean the cell height (multiline cells).

I tried to use different identifiers, but that didn't worked. Here is the code:

NSString *identifier;
if (thisViewMode) {
    identifier = @"thisViewMode";
} else if ((indexPath.section == 1) && thatViewMode) {
    identifier = @"thatViewMode";
} else {
    identifier = @"CellIdentifier";
}

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
    cell = [self CreateMultilinesCell:identifier];
}

thatViewMode is only called once, which isn't right because I have more cells in my second section. If I change the content of the first cell in the first section, the height of the first cell in the second section also changes too. Normally each cell should have it's own cell height, but that isn't the case here.

Is there a problem that I can't use different cell identifiers on the same table view?

A: 

I forgot to also adapt heightForRowAtIndexPath so that I make a differentiation between the sections.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 1) {
        // do something
    } else {
        // do something different
    }
    return ...
}
testing