1

I have a nib. It has an NSScrollView with an NSTableView inside it. I would like this tableview to automatically expand to fill its entire superview.

I'm trying to use autolayout but I have no idea how to add the constraints. Since the nib has no view objects other than the scroll view - I don't get how you reference the superview.
None of the auto layout buttons at the bottom of the nib editor give me any options, everything is grayed out.

I'm using Interface Builder, Xcode 5, OS X 10.9.2.
Not iOS!

cacau
  • 3,606
  • 3
  • 21
  • 42
jsd
  • 7,673
  • 5
  • 27
  • 47
  • Please tell how are you experiencing the problem exactly and how is view controller presented (added to window manually, added as part of other nib, etc.)? – user3125367 Mar 05 '14 at 10:28
  • I'm not using a view controller. Just adding a scrollview directly to the main window. – jsd Mar 05 '14 at 17:01

2 Answers2

0

You can't. But you probably have the code where this view controller is instantiated. There you need to add constraints manually.

user3125367
  • 2,920
  • 1
  • 17
  • 17
0

To get started have a look at the WWDC sessions, in particular

The learning curve is a bit steep but it'll be worth your while.

Check out the Content Hugging setting for your view to make sure it's allowed to expand.

Also check the warnings in the Interface Builder editor and let it add missing constraints if you're not sure what to do.

And always pay attention to the Autolayout warnings in the Xcode console!

This blog post has some nice hints as well:
http://oleb.net/blog/2013/03/things-you-need-to-know-about-cocoa-autolayout/

Some more specific tips:

Autolayout is enabled for your .nib/.xib, right? Just making sure.

The super view is referenced kind of implicitly when you set the constraints for your view, you don't set constraints for the top-level view in the .xib (if I recall correctly, no Xcode at hand right now).

cacau
  • 3,606
  • 3
  • 21
  • 42
  • The original problem is about how to make top view in nib extandable when it is added to *another* view later. Obviously, this only depends on constraints in *that* view. – user3125367 Mar 05 '14 at 10:25
  • I've watched all the WWDC stuff. None of the options for autolayout are enabled - not automatic issue resolution, not add suggested constraints. I guess autolayout in IB can't function unless there's more than one view. – jsd Mar 05 '14 at 17:02