Xcode10:无法使用NSWindow制表模式同时满足约束

时间:2018-07-18 08:45:17

标签: xcode10

我最近将一个复杂的应用程序转换为Swift 4.2。这是一个基于文档的应用程序。令我惊讶的是,我注意到当我合并所有文档窗口时,应用程序崩溃了。好吧,一开始我以为这是我的代码有问题,但是错了,即使是基于文档的新项目也有这些问题:

    2018-07-18 10:10:49.080969+0200 testApp[41504:213340] [Layout] Unable to simultaneously satisfy constraints:
(
    "<NSLayoutConstraint:0x600002165540 _leftBorderView.width == 1   (active, names: _leftBorderView:0x600003338640 )>",
    "<NSLayoutConstraint:0x600002165630 _rightBorderView.width == 1   (active, names: _rightBorderView:0x6000033385a0 )>",
    "<NSLayoutConstraint:0x600002165590 H:[_leftBorderView]-(0)-[_backgroundView]   (active, names: _backgroundView:0x600003338460, _leftBorderView:0x600003338640 )>",
    "<NSLayoutConstraint:0x6000021655e0 H:[_backgroundView]-(0)-[_rightBorderView]   (active, names: _rightBorderView:0x6000033385a0, _backgroundView:0x600003338460 )>",
    "<NSLayoutConstraint:0x6000021654f0 H:|-(0)-[_leftBorderView]   (active, names: _leftBorderView:0x600003338640, _vibrantContentView:0x600003338500, '|':_vibrantContentView:0x600003338500 )>",
    "<NSLayoutConstraint:0x600002165680 H:[_rightBorderView]-(0)-|   (active, names: _vibrantContentView:0x600003338500, _rightBorderView:0x6000033385a0, '|':_vibrantContentView:0x600003338500 )>",
    "<NSLayoutConstraint:0x600002164ff0 H:|-(0)-[_vibrantContentView]   (active, names: _vibrantContentView:0x600003338500, _contentView:0x600003338320, '|':_contentView:0x600003338320 )>",
    "<NSLayoutConstraint:0x600002165040 _vibrantContentView.trailing == _contentView.trailing   (active, names: _vibrantContentView:0x600003338500, _contentView:0x600003338320 )>",
    "<NSLayoutConstraint:0x600002164e60 H:|-(0)-[_contentView]   (active, names: _contentView:0x600003338320, '|':NSTabButton:0x1017a5870'Untitled 2' )>",
    "<NSLayoutConstraint:0x600002164eb0 _contentView.trailing == NSTabButton:0x1017a5870'Untitled 2'.trailing   (active, names: _contentView:0x600003338320 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x60000216a9e0 h=--& v=--& NSTabButton:0x1017a5870'Untitled 2'.width == 1   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x600002165630 _rightBorderView.width == 1   (active, names: _rightBorderView:0x6000033385a0 )>

Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens.  And/or, set a symbolic breakpoint on LAYOUT_CONSTRAINTS_NOT_SATISFIABLE to catch this in the debugger.
(lldb) 

好。这似乎是appkit为合并窗口顶部的选项卡按钮生成的约束问题(如果我错了,请纠正我)。无论如何,我还是需要使用Xcode 10,所以我的问题是:有一种方法可以通过编程方式取消行为的约束或子类?

编辑

Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens.  And/or, set a symbolic breakpoint on LAYOUT_CONSTRAINTS_NOT_SATISFIABLE to catch this in the debugger.
2018-07-18 18:45:58.321943+0200 testApp[43926:361604] *** Assertion failure in BOOL _NSWindowDidReachDisplayCycleLimit(NSWindow *, NSDisplayCycle *, NSDisplayCycleIdentifier, NSUInteger, NSString *)(), /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1643.10.101/AppKit.subproj/NSWindow_DisplayCycle.m:236
2018-07-18 18:45:58.325357+0200 testApp[43926:361604] [General] An uncaught exception was raised
2018-07-18 18:45:58.325396+0200 testApp[43926:361604] [General] The window has been marked as needing another display pass, but it has already had more display passes than there are views in the window.
2018-07-18 18:45:58.331325+0200 testApp[43926:361604] [General] (
    0   CoreFoundation                      0x00007fff3c8d5d0b __exceptionPreprocess + 256
    1   libobjc.A.dylib                     0x00007fff68781243 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff3c8d9b94 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x00007fff3ed7bdd3 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
    4   AppKit                              0x00007fff3a5c41c6 -[NSWindow(NSDisplayCycle) _postWindowNeedsDisplayUnlessPostingDisabled] + 1214
    5   AppKit                              0x00007fff39dcc27b -[NSView _setSuperview:] + 778
    6   AppKit                              0x00007fff39dcbc10 -[NSView addSubview:] + 212
    7   AppKit                              0x00007fff3a883bc6 -[_NSVisualizedConstraintsView viewWillDraw] + 599
    8   AppKit                              0x00007fff3a655ba7 _NSViewWillDraw + 45
    9   AppKit                              0x00007fff3a651dcc NSViewSendViewWillDrawToSubviews + 247
    10  AppKit                              0x00007fff3a655ba7 _NSViewWillDraw + 45
    11  AppKit                              0x00007fff39f13bd9 -[NSView displayIfNeeded] + 901
    12  AppKit                              0x00007fff39f13823 -[NSWindow displayIfNeeded] + 270
    13  AppKit                              0x00007fff3a5c5597 __NSWindowGetDisplayCycleObserverForDisplay_block_invoke + 722
    14  AppKit                              0x00007fff3a3b21af NSDisplayCycleObserverInvoke + 170
    15  AppKit                              0x00007fff3a696f5e NSDisplayCycleFlush + 1073
    16  QuartzCore                          0x00007fff47c8f383 _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 49
    17  QuartzCore                          0x00007fff47c8da56 _ZN2CA11Transaction6commitEv + 186
    18  AppKit                              0x00007fff3a609d26 -[NSWindowStackController _syncInactiveTabWindowSizesForSnapshot] + 466
    19  AppKit                              0x00007fff3a609d70 -[NSWindowStackController _openTabPickerAnimated:] + 30
    20  AppKit                              0x00007fff3a19ebdc -[NSWindow(NSWindowTabbing) _toggleTabOverview:animated:] + 163
    21  AppKit                              0x00007fff3a19ec5c -[NSWindow(NSWindowTabbing) _toggleTabOverview:] + 72
    22  AppKit                              0x00007fff3a5362b5 -[NSApplication(NSResponder) sendAction:to:from:] + 312
    23  AppKit                              0x00007fff39fee7b7 -[NSMenuItem _corePerformAction] + 323
    24  AppKit                              0x00007fff39fee528 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 114
    25  AppKit                              0x00007fff3a06d65e -[NSMenu performActionForItemAtIndex:] + 133
    26  AppKit                              0x00007fff3a06d5c9 -[NSMenu _internalPerformActionForItemAtIndex:] + 94
    27  AppKit                              0x00007fff3a06d3f8 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 106
    28  AppKit                              0x00007fff39f436da NSSLMMenuEventHandler + 902
    29  HIToolbox                           0x00007fff3bacf719 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1502
    30  HIToolbox                           0x00007fff3bacea76 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 371
    31  HIToolbox                           0x00007fff3bae3bfd SendEventToEventTarget + 39
    32  HIToolbox                           0x00007fff3bb2cacf _ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef + 380
    33  HIToolbox                           0x00007fff3bb55606 SendMenuCommandWithContextAndModifiers + 49
    34  HIToolbox                           0x00007fff3bb555bc SendMenuItemSelectedEvent + 191
    35  HIToolbox                           0x00007fff3bb5549f _ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 96
    36  HIToolbox                           0x00007fff3bb55e49 _ZL14MenuSelectCoreP8MenuData5PointdjPP13OpaqueMenuRefPt + 603
    37  HIToolbox                           0x00007fff3bb55b5e _HandleMenuSelection2 + 453
    38  AppKit                              0x00007fff39f35aff _NSHandleCarbonMenuEvent + 223
    39  AppKit                              0x00007fff3a1785ca _DPSEventHandledByCarbon + 54
    40  AppKit                              0x00007fff3a5343d0 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2220
    41  AppKit                              0x00007fff39de08ae -[NSApplication run] + 699
    42  AppKit                              0x00007fff39db0917 NSApplicationMain + 782
    43  testApp             0x00000001002d735d main + 13
    44  libdyld.dylib                       0x00007fff697553ed start + 1
    45  ???                                 0x0000000000000003 0x0 + 3

0 个答案:

没有答案