在10.12中有几个重大的变化,但我认为最大的变化是新的自动布局系统(或者是修改/重写的旧系统...谁知道呢)。我准备了一个简单的项目来演示这个问题。它涉及到通过按钮折叠分割视图项。这只会在10.12上发生。你需要做的就是编译项目并点击按钮。会出现一个错误:
2016-10-04 15:10:28.284296 test-12[64932:7425277] [Layout] Detected missing constraints for . It cannot be placed because there are not enough constraints to fully define the size and origin. Add the missing constraints, or set translatesAutoresizingMaskIntoConstraints=YES and constraints will be generated for you. If this view is laid out manually on macOS 10.12 and later, you may choose to not call [super layout] from your override. Set a breakpoint on DETECTED_MISSING_CONSTRAINTS to debug. This error will only be logged once.
设置断点后,我们可以发现有问题的视图是:
2016-10-04 15:10:28.284296 test-12[64932:7425277] [Layout] Detected missing constraints for . It cannot be placed because there are not enough constraints to fully define the size and origin. Add the missing constraints, or set translatesAutoresizingMaskIntoConstraints=YES and constraints will be generated for you. If this view is laid out manually on macOS 10.12 and later, you may choose to not call [super layout] from your override. Set a breakpoint on DETECTED_MISSING_CONSTRAINTS to debug. This error will only be logged once.
设置断点后,我们可以发现有问题的视图是:
(lldb) po $arg1
<NSSplitDividerView: 0x618000161980>
我是完全错误的,还是10.12存在明显问题?如果可能,请建议如何预防这种类型的错误。
项目可以从Github下载。
再次感谢您的帮助。
I. Nikolov
NSSplitViewController
中的splitView(_ splitView: NSSplitView, shouldHideDividerAt dividerIndex: Int) -> Bool
方法中返回false
来解决了这个问题。 - LShi