开发者

Use two different cell identifier on same table view

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?


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 ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜