Note that there are some explanatory texts on larger screens.

plurals
  1. POView-based NSTableView with rows that have dynamic heights
    primarykey
    data
    text
    <p>I have an application with a view-based <code>NSTableView</code> in it. Inside this table view, I have rows that have cells that have content consisting of a multi-row <code>NSTextField</code> with word-wrap enabled. Depending on the textual content of the <code>NSTextField</code>, the size of the rows needed to display the cell will vary. </p> <p>I know that I can implement the <code>NSTableViewDelegate</code> method -<code>tableView:heightOfRow:</code> to return the height, but the height will be determined based on the word wrapping used on the <code>NSTextField</code>. The word wrapping of the <code>NSTextField</code> is similarly based on how wide the <code>NSTextField</code> is… which is determined by the width of the <code>NSTableView</code>.</p> <p>Soooo… I guess my question is… what is a good design pattern for this? It seems like everything I try winds up being a convoluted mess. Since the TableView requires knowledge of the height of the cells to lay them out... and the <code>NSTextField</code> needs knowledge of it's layout to determine the word wrap… and the cell needs knowledge of the word wrap to determine it's height… it's a circular mess… and it's driving me <em>insane</em>.</p> <p>Suggestions?</p> <p>If it matters, the end result will also have editable <code>NSTextFields</code> that will resize to adjust to the text within them. I already have this working on the view level, but the tableview does not yet adjust the heights of the cells. I figure once I get the height issue worked out, I'll use the -<code>noteHeightOfRowsWithIndexesChanged</code> method to inform the table view the height changed… but it's still then going to ask the delegate for the height… hence, my quandry.</p> <p>Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload