xcode – NSToolbar – 工具栏空间项 – 打破默认约束

如果我从应用程序更改NSToolbar的大小,通过小尺寸,图标&文本,应用程序制动未满足的约束(试图关闭自动布局,或让应用程序生成其布局)

我的窗口包含一个工具栏和一个(左/右)拆分视图

[81687:303] Unable to simultaneously satisfy constraints:
(
    "<NSAutoresizingMaskLayoutConstraint:0x100635620 h=--& v=--& V:[NSToolbarItemViewer:0x101b4d930(5)]>","<NSAutoresizingMaskLayoutConstraint:0x100634b30 h=--& v=-&- V:|-(11)-[_NSToolbarSpace:0x101b49a00]   (Names: '|':NSToolbarItemViewer:0x101b4d930 )>","<NSAutoresizingMaskLayoutConstraint:0x100634ad0 h=--& v=-&- V:[_NSToolbarSpace:0x101b49a00]-(12)-|   (Names: '|':NSToolbarItemViewer:0x101b4d930 )>"
)

Will attempt to recover by breaking constraint 
<NSAutoresizingMaskLayoutConstraint:0x100634b30 h=--& v=-&- V:|-(11)-[_NSToolbarSpace:0x101b49a00]   (Names: '|':NSToolbarItemViewer:0x101b4d930 )>

Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens.  And/or,break on objc_exception_throw to catch this in the debugger.

当我可视化约束错误

编辑:看起来像“工具栏空间项目”打破约束,如果我删除它,我运行正常

解决方法

看起来像一个bug,我最后添加了我自己的空间项目,使用空白的NSView

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...