简体   繁体   English

使用自动布局的NSTableView在单元格视图上创建宽度约束

[英]NSTableView using autolayout creates width constraint on cell view

I'm using a view-based NSTableView with Auto Layout turned on. 我正在使用基于视图的NSTableView并已启用“自动布局”。 Auto Layout provides the cell views with two horizontal constraints: a Cell_MinX that is tied to its NSTableRowView's leading edge, and a Cell_Width constraint that is adjusted based on the width of the table. “自动布局”为单元格视图提供了两个水平约束:绑定到其NSTableRowView前沿的Cell_MinX,以及根据表的宽度进行调整的Cell_Width约束。

在此处输入图片说明

However, when the window's width is resized > 1000 points, the Cell_Width constraint stops increasing at 1000 and the width constraint locks at 1000 points until the window's width is smaller than this limit. 但是,当窗口的宽度调整为大于1000点的大小时,Cell_Width约束将在1000处停止增加,并且宽度约束将在1000点处锁定,直到窗口的宽度小于此限制。 This seems to be an arbitrary value inserted by the table view, and I can't figure out how to ensure that value is always the width of the table. 这似乎是表格视图插入的任意值,而且我不知道如何确保该值始终是表格的宽度。 I built the table view in IB which doesn't permit creating constraints on the table's cell view. 我在IB中建立了表格视图,不允许在表格的单元格视图上创建约束。 I created a sample project to demonstrate the problem. 我创建了一个示例项目来演示该问题。 Here's Xcode's view debugger with the window's width sized greater than 1000. 这是Xcode的视图调试器,窗口的宽度大于1000。

在此处输入图片说明

This is not arbitrary. 这不是任意的。 Interface builder sets the maximum Table Column size to 1000. If you remove all the columns, set it to zero, then add a single column, and make sure it sets it to View based table view, then it will set it to the maximum allowed size (a very big number). 界面构建器将“表列”的最大大小设置为1000。如果删除所有列,将其设置为零,然后添加单个列,并确保将其设置为“基于视图的表”视图,则将其设置为最大允许值大小(非常大的数字)。 Or you can just set the maximum size yourself in interface builder. 或者,您也可以在界面生成器中自行设置最大大小。

表格栏最大尺寸

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM