I am trying to create a UITableView
with variable height rows as explained in the answer to this question
My problem is each cell contains a UIWebView
with different (statically loaded) content I can't figure out how to calculate the proper height based on the content. Is there a way to do this? I've tried things like this:
(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
WebViewCell *cell = (WebViewCell*)[self tableView:tableView cellForRowAtIndexPath:indexPath];
[cell setNeedsLayout];
[cell layoutIfNeeded];
return cell.bounds.size.height;
}
The cells themselves are loaded from a nib, which is simply a UITableViewCell
containing a UIWebView
. (It would also be fine if the cells just adjusted themselves to the largest of the html content, though variable height would be nicer).