NSView 控件不调整大小?
我有一个 NSView ,里面有一个 NSTableView 。
如果视图如下所示:
> Scollview(和 tableview)的位置属性如下所示:
那么为什么当我调整视图大小时,它看起来像这个:
我的自动调整大小属性设置不正确吗?根据我的理解,他们应该是?
I have a NSView with a NSTableView inside of it.
If the view looks like this:
And the size & position properties for the Scollview (and tableview) look like this:
Then why when I resize the view, does it look like this:
Are my autosizing properties not set correctly? To my understanding they should be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更清楚地说,在 Interface Builder 中设计视图时,您不会看到自动调整大小行为,除非子视图的边框与父视图的相应边框一致并且启用了实时自动调整大小。
存在这种行为是因为调整父视图的大小可用于指示您希望子视图区域和父视图区域之间有一定的边距 - 例如,子视图的右边框和父视图的右边框之间可能有 100pt 的边距,然后增加通过拖动超级视图手柄将该边距调整为 200pt。
编辑: 另一方面,如果您想调整超级视图的大小,同时根据自动调整大小蒙版保持边距,则可以在按住 alt/option 键的同时拖动超级视图手柄。
使用 Cocoa Simulator(文件 -> 模拟界面)来测试您的界面,包括自动调整大小行为。
To make it clearer, you won’t see autoresizing behaviour whilst designing your view in Interface Builder unless the border of the subview coincides with the corresponding border of the superview and Live Autoresizing is enabled.
This behaviour exists because resizing the superview can be used to indicate that you want a certain margin between the subview area and the superview area — for instance, you might have a 100pt margin between the subview’s right border and the superview’s right border, and then increase that margin to, say, 200pt by dragging the superview handles.
Edit: On the other hand, if you want to resize the superview whilst keeping the margins according to the autoresizing mask, you can drag the superview handles whilst holding the alt/option key.
Use Cocoa Simulator (File -> Simulate Interface) in order to test your interface, including autoresizing behaviour.
仅当您在“尺寸信息”面板中手动输入尺寸时,带有滚动视图的表格才会自动调整为您的视图尺寸。如果您用鼠标拖动视图的手柄,它们将不会自动调整大小。
The table with its scroll view will autoresize to your view's size only if you enter dimensions in by hand in Size info panel. They will not autoresize if you drag view's handles with mouse.