Question

The problem here is how to add an NSPopUpButton in Xcode 4's Interface Builder pane without IB also adding an (unwanted) width constraint.

In Interface Builder in Xcode 4.3 on Lion using Auto Layout, if you add a normal button to a view, Xcode will add constraints that pin the button to one of the vertical borders and one of the horizontal borders of the view. The width is determined by by the button's intrinsic content size.

If I do the same thing with an NSPopUpButton, Interface Builder adds a width constraint to the button, that I can't find a way to get rid of in IB.

I have tried to change the priority of the width constraint (which would suit my intent, as long as I can make it lower than my content compression resistance), but it adds a new one at 1000 immediately.

Any ideas about how to do it in Interface Builder, or do I have to do it programmatically?

Was it helpful?

Solution

It actually turns out that there is a simple solution:

Under the Editor menu, select Size to Fit Content (Cmd-=).

OTHER TIPS

With Xcode 4 you need to add constraints enough to satisfy layout then remove the ones that are unneeded.

With Xcode 5 it starts out with none so you add then as you go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top