UITableView variable row height calculations
I'm working on an iPhone app that needs to display variable length text content in UITableView cells. Since the text can run to any number of lines, each row can have a different height. I've read through the UITableView/UITableViewDelegate/UITableViewCell documentation, and looked at the various examples from the dev center. The solution I've come up with uses the tableView:heightForRowAtIndexPath: method to return the calculated row height for each row.
My problem is that I can't come up with an elegant way to calculate the row height. Right now I'm pulling the model object for the row in question and using the NSString:sizeWithFont:constrainedToSize:lineBreakMode method to get a CGSize object, then returning the height. But I'm duplicating a lot of logic that is in the UITableCell object's layoutSubviews method.
I tried calling cellForRowAtPath from heightForRowAtIndexPath, then returning cell.bounds.size.height, but that doesn't work (seems to cause infinite recursion or something... not sure why). Has anyone had this problem? Is there a "best practice" sort of solution? I'm beginning to wonder if I shouldn't just dump everything into a UIWebView and mark stuff up in HTML...
MacBook Pro, Mac OS X (10.5.2)