我正在使用基于视图的表视图。每个单元格都是一个带有自动布局约束的简单NSView
,单元格包含多个视图,其中主要是NSTableView
(包含在强制NSScrollView
中,而后者又包含在一个简单的NSView
中tableView:viewForTableColumn:row
)。
调用makeViewWithIdentifier
委托方法后,我使用Unable to simultaneously satisfy constraints:
(
"<NSLayoutConstraint:0x10ab8a020 V:[NSView:0x100423720(132)]>",
"<NSLayoutConstraint:0x1004581e0 NSScrollView:0x1004c82c0.bottom == NSView:0x100423720.bottom>",
"<NSLayoutConstraint:0x100458340 V:|-(0)-[NSScrollView:0x1004c82c0] (Names: '|':NSView:0x100423720 )>",
"<NSAutoresizingMaskLayoutConstraint:0x10138d730 h=-&- v=-&- V:[NSClipView:0x1004ca010]-(220)-| (Names: '|':NSScrollView:0x1004c82c0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x10138d6d0 h=-&- v=-&- V:|-(0)-[NSClipView:0x1004ca010] (Names: '|':NSScrollView:0x1004c82c0 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1004581e0 NSScrollView:0x1004c82c0.bottom == NSView:0x100423720.bottom>
创建我的观点。
然后我设置了视图。在许多其他事情中,单元格的内部表视图获取数据源。
但是,如果视图是正在被回收的视图,我会在日志中收到以下熟悉的错误:
tile
注意内部剪辑视图在这种情况下如何将其约束设置为220的高度。这实际上是表的 previous 高度。
无论我做什么,表都没有刷新它的高度:我尝试更改数据源,调用translatesAutoresizingMaskIntoConstraints
,强制布局,强制约束更新,删除表视图和重新添加它没什么帮助。
奇怪的是,布局约束首先存在,因为我的所有视图都禁用了tableView.constraints
。事实上,如果我将"<NSAutoresizingMaskLayoutConstraint:0x1013c2360 h=--& v=--& H:|-(-100)-[NSScroller:0x1030ea3c0] (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c23c0 h=--& v=--& H:[NSScroller:0x1030ea3c0(15)]>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c2420 h=--& v=--& V:|-(-100)-[NSScroller:0x1030ea3c0] (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c2290 h=--& v=--& V:[NSScroller:0x1030ea3c0(102)]>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c2de0 h=--& v=--& H:|-(-100)-[NSScroller:0x1030ea620] (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c2e50 h=--& v=--& H:[NSScroller:0x1030ea620(223)]>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c2eb0 h=--& v=--& V:|-(-100)-[NSScroller:0x1030ea620] (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c2f10 h=--& v=--& V:[NSScroller:0x1030ea620(15)]>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c4500 h=-&- v=-&- H:|-(0)-[NSClipView:0x1030ea880] (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c4570 h=-&- v=-&- H:[NSClipView:0x1030ea880]-(0)-| (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c45d0 h=-&- v=-&- V:|-(0)-[NSClipView:0x1030ea880] (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1013c4630 h=-&- v=-&- V:[NSClipView:0x1030ea880]-(110)-| (Names: '|':ScrollViewWithoutScrolling:0x1030e8c80 )>"
转储到日志中,最初没有约束,但 wham ,突然有一大堆,实际上有一堆奇怪的重复约束:< / p>
removeConstraint
这看起来很像我的错误。 Something 正在创建这些约束(做错了),但不是我。我尝试删除它们,只是为了看看会发生什么,但constraints
不会删除它们,或者translatesAutoresizingMaskIntoConstraints
正在重新创建它们。
只有一个视图启用了{{1}}:单元格视图本身。那是因为如果我禁用它,它会变得奇怪,完全是空的。
一般来说,基于视图的表格中的单元格视图上的autolayout似乎是在寻找麻烦,但我希望有一种方法可以使它工作。