Search code examples
xcodemacosnstableviewautoresizesubviews

Shouldn't an NSTableview autoresize when its superview resizes?


I have an NSTableview on the contentview of an NSWindow. When I resize the window, I would like the height of the NSTableview to resize. This isn't working.

To make sure I haven't set something incorrectly, I created a new mac project, view-based, storyboard. In IB, I added an NSTableView to the view. It looks like the default is to have autoresizing on, so I made no changes. Run this sample project, resize the window and the tableview does not resize. I guess I am missing something. What is it??

BTW, I am using xCode 6.3


Solution

  • • While viewing the xib, select the Bordered Scroll View that contains your table.

    • In the lower-right of the xib canvas, you'll see 4 icons. The 2nd icon is called "Pin" if you hover your mouse over it. Click that.

    • In the view that pops up, click the 4 red constraint connectors, then click "Add 4 Constraints".