Wrapping Text in Table View Cell


I have a table view and I need text to wrap in some of the columns. In IB I dragged a NSTextFieldCell into the table view, checked out the settings in the inspector, (Line Breaking is set to Word Wrap) but when I run the app the text in the cell does not wrap. Is there something I am missing? I’m using version 2.4.1 on mac OS 10.4.10.

Do you mean that when the text exceeds the width of the cell that the row for that cell grows in height to accommodate the text’s size when wrapped? If so, this is not a feature that can be “turned on” with a switch in IB. You need to implement the delegate method “tableView:heightOfRow:” in a custom subclass of NSTableView. Every time the table draws a row, your code will need to get the string, programmatically determine the size needed to draw it, then return the height in this method. This is not a simple task for those not experienced in obj-c, and may not even be compatible with your applescript datasource.

See also:
NSTableView Class References > “tableView:heightOfRow:” method

I was following the instructions from this thread:


So you’re saying that even though I have a NSTextFieldCell placed in my table and have Line Breaking set to word wrap and Layout set to wraps that I still need to do some C in order to view the wrapped text?