views:

479

answers:

4

Let's say I have a split view, and I want to fill half of it with a table view (a fairly common use case, I would think). Is there any way to tell the table view to size itself to fit the split view or do I really have to size it manually?

+1  A: 

As far as I know, doing it manually is the only way to go. However, if you turn on "snap to cocoa guidelines", the inner view will snap to the edges of the enclosing view as you drag towards them. This makes it easier than having to manually mouse the edges into place, or manually edit the sizes to match.

e.James
+1  A: 

You can set all of the springs and struts of the table view to "on" in the size inspector and that will cause the table view to fill the split view. Alternatively, you can use the outline view in the main document window to place the tableview's enclosing scroll view directly into the splitview instead of in an intermediary custom view.

+1  A: 

I've done this, the way Jon Hess mentions first. Assuming you're using Interface Builder version 3:

  1. Drag and resize your GUI (tableview from what I understand?) component to fit into the enclosing area the way you want it.

  2. Click it to select it.

  3. Press Command-Shift-I to open the inspector window for this GUI component. The inspector window should now actually show that you've selected a "Scroll View".

  4. Click the "ruler" heading to be able to set the sizing. You'll see to the right an animated representation of how your GUI component will behave within its enclosing GUI component, and to the left another represenation of the same, without animation, but with four springs and two struts that you can turn on or off.

  5. Turn all six things on, making them red.

Voilà :-)

harms
+2  A: 

It's generally easier to create the subviews first, then use the Layout/Embed Objects In/Split View menu item to create the split view around them.

Peter Hosey