I have a single column NSTableView
(view based) with a TextField
. I am using autolayout and IB. Most of the views in the window are resizable, in particular the table. I am putting attributed text in the TextField. If the application starts with the table width smaller or equal to the width of the TextField (as specified in IB), then everything works great. On the other hand, if the table is initially presented too wide, then the TextField is too small and the text wraps leaving a large amount of left hand space. Resizing the table automatically corrects the TextField width, until the application is restarted.
Inside tableView viewForTableColumn I get an NSTableCellView with the standard makeViewWithIdentifier. I tried forcing the frame size larger, but that had no effect. The frame matches the values from the nib (as one would expect). The only constraints are on the Table Cell View, which force it to grow and shrink with the table resizing, BUT only after the table width is shrunk by the user.
Is there something going on with the Bordered Scroll View that holds the table? Where would I force the NSTableCellView to reconcile its width?
before manual resize by user:
after resizing:
Thanks...
Just ran across a similar problem with XCode 12.5. A cell in an NSTableView that was in a xib that was built with an earlier version of Xcode started only filling ~1/2 of the column width after any modification was made to the xib even if the change had nothing remotely to do with the NSTableView. A diff between the working xib and the slightly modified one (only changed one dimension of another control by 1 pixel) showed 27 changes all over the document, mostly slight pixel changes all through the xib. No amount of fidgeting with constraints would fix this. By sheer luck I happened to discover that somehow the TableView's "Style" in the Attributes panel had changed to "Automatic" when the xib was modified with a later version of XCode. Changing the style to "Full Width" makes the cell fill the whole column.