The proper height for my custom UITableViewCells depends on their width. Unfortunately, it is difficult to know the actual content area width of a cell in -tableView:heightForRowAtIndexPath:, since the only information I have to work with is the tableview. Several factors can change the content width so it is not equal to tableView.bounds.size.width; the one I’m struggling with now is the section index. (Another is if the tableview is grouped.)
Is there a good way in general to get the cell content width from just the tableView?
Failing that, is there any way to get the width of the section index, so that I can subtract it from the bounds width? (I don’t want to hard code it, since that won’t be portable across devices.)
Note: This is not a dup of Need access to the cell in the tableView:heightForRowAtIndexPath: because the solution there is just to use the bounds. Nor is it a dup of Get tableView:heightForRowAtIndexPath: to happen after tableView:cellForRowAtIndexPath:? since the solution there is to hard code a constant (265.0), which isn’t portable across devices.
Here’s what I got working. It’s ugly, but it works, at least in all the cases I could find.