Get tableView:heightForRowAtIndexPath: to happen after tableView:cellForRowAtIndexPath:?

Posted by Triz on Stack Overflow See other posts from Stack Overflow or by Triz
Published on 2009-08-30T01:21:26Z Indexed on 2011/11/24 1:50 UTC
Read the original article Hit count: 210

Filed under:
|
|

I've got some UITableViewCells that need to change their height depending on the length of the strings inside. I'm calculating the necessary height inside tableView:cellForRowAtIndexPath:, and then storing it in a variable (self.specialRowHeight). Then I've got:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == SPECIAL_SECTION) {
        return self.specialRowHeight;
    }
    else {
        return 44;
    }
}

Except that seems to be getting called before the tableView:cellForRowAtIndexPath: bit, so it's always zero.

Is there a way around this, or perhaps a different way to do it?

Thanks!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa-touch