2

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?

4

2 回答 2

6

事实证明,有一个简单的解决方案:

在编辑器菜单下,选择Size to Fit Content(Cmd-=)。

于 2012-06-23T11:08:49.670 回答
1

使用 Xcode 4,您需要添加足以满足布局的约束,然后删除不需要的约束。

在 Xcode 5 中,它一开始是没有的,所以你可以随时添加。

于 2013-09-12T04:40:15.190 回答