0
votes

Along the same lines as How to Expand NSTableCellView Width When Resizing Column in NSTableView - but the solution there isn't working for me...

I've got a Mac app in Xcode 12.3 with some table views which adjust their width according to the size of the window - but I cannot get the table contents to adjust their width to fill the columns.

Here's a view debug of what I'm seeing:

View Debug of NSTableView

The NSTableCellView width is 287, but the NSTableRowView is 343.

I've got Autoresizes Subviews turned on all the way down the hierarchy, and I've got leading and trailing constraints from the Table View Cell to its superview - but I can't get it working.

Any clues? Many thanks!

1
What is the width of the column? Is the cell view not adjusting to the column or is the column not adjusting to the table view?Willeke
The NSTableView has Autoresizes Subviews enabled, and the NSTableColumn is currently set to Width 331 (>40, <1000 Constraints). Of course, the NSTableColumn doesn't allow Autolayout constraints to be added - but it has been dragged to be the same width as the table in IB.Moisie
From the view debug, it looks like there's no such thing as a column when it's run - but the discrepancy is between the tableCellView.width and tableRowView.width.Moisie

1 Answers

0
votes

Ah - I think another part of the auto layout was infecting the table:

I have two boxes, side-by-side in the window, each with a table inside it. Each box had defined leading and trailing constraints, and were set to be of equal width as each other.

With doing nothing else to resolve the problem, I changed this so I had a vertical guide line centred in the view, and each box has a defined leading and trailing constraint between the view edge and the guide line - so I don't have to set the boxes as equal width.

Now my cells nearly resize completely correctly. The remaining issues I can live with for now:

  • The cells start off too narrow, but if I resize the window width to compress the cells, they then follow the window width correctly if I expand it;
  • At some point near the minimum width, horizontal scrollers briefly appear in the table views as I change the window width.

Hope this might help someone else.