2

我在 NSView 中有一个基于视图的 NSOutlineView。当视图出现在我的应用程序中时,大纲视图会不断闪烁。awakeFromNib 被重复调用,其中包含 [myOutlineView reloadData]。但是,一旦我调整窗口大小(因此是视图),闪烁就会消退,并且不再调用 awakeFromNib。

我认为闪烁是由于在 awakeFromNib 中重复调用 reloadData 引起的。我无法确定的是为什么 awakeFromNib 会被连续调用。我知道每次 NSOutline (here)创建 NSTableCellView 时都会调用它,但这并不能解释为什么会连续调用它。

由于一旦我调整了窗口大小,这种行为就会停止,我对嵌入 NSOutlineview 的 NSScrollView 持怀疑态度,但我现在不知道如何确认这一点或更重要的是如何修复它。

那么任何人都可以就可能导致这种行为的原因给我一些指导吗?

编辑

这是在 awakeFromNib 处中断的堆栈跟踪,基于此看起来确实像创建调用 awakeFromNib 的 NSTableCellView,但为什么要连续完成?

    frame #1: 0x00007fff8cfd3b5f AppKit`-[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1223
frame #2: 0x00007fff8d077e7c AppKit`-[NSNib _instantiateNibWithExternalNameTable:] + 600
frame #3: 0x00007fff8d19139b AppKit`-[NSNib instantiateNibWithExternalNameTable:] + 17
frame #4: 0x00007fff8d09c278 AppKit`-[NSTableRowData _unarchiveViewWithIdentifier:owner:] + 526
frame #5: 0x00007fff8d09bedd AppKit`-[NSOutlineView makeViewWithIdentifier:owner:] + 48
frame #6: 0x0000000100039c03 Allocator`-[SBRebalanceViewController outlineView:viewForTableColumn:item:](self=0x00006080003c03c0, _cmd=0x00007fff8da60816, outlineView=0x0000000100427ce0, tableColumn=0x000060800009f0e0, item=0x000060000084b580) + 1315 at SBRebalanceViewController.m:146
frame #7: 0x00007fff8d09f964 AppKit`-[NSTableView(NSTableViewViewBased) makeViewForTableColumn:row:] + 77
frame #8: 0x00007fff8d09ec97 AppKit`-[NSTableRowData _addViewToRowView:atColumn:row:] + 305
frame #9: 0x00007fff8d09e9ca AppKit`-[NSTableRowData _addViewsToRowView:atRow:] + 191
frame #10: 0x00007fff8d09babe AppKit`-[NSTableRowData _addRowViewForVisibleRow:withPriorView:] + 421
frame #11: 0x00007fff8d09b83c AppKit`-[NSTableRowData _addRowViewForVisibleRow:withPriorRowIndex:inDictionary:withRowAnimation:] + 278
frame #12: 0x00007fff8d09a906 AppKit`-[NSTableRowData _unsafeUpdateVisibleRowEntries] + 1640
frame #13: 0x00007fff8d09a19c AppKit`-[NSTableRowData updateVisibleRowViews] + 230
frame #14: 0x00007fff8d099dc4 AppKit`-[NSTableView layout] + 165
frame #15: 0x00007fff8d098e1d AppKit`-[NSView _layoutSubtreeWithOldSize:] + 325
frame #16: 0x00007fff8d09903e AppKit`-[NSView _layoutSubtreeWithOldSize:] + 870
frame #17: 0x00007fff8d09903e AppKit`-[NSView _layoutSubtreeWithOldSize:] + 870
frame #18: 0x00007fff8d09903e AppKit`-[NSView _layoutSubtreeWithOldSize:] + 870
frame #19: 0x00007fff8d09903e AppKit`-[NSView _layoutSubtreeWithOldSize:] + 870
frame #20: 0x00007fff8d09903e AppKit`-[NSView _layoutSubtreeWithOldSize:] + 870
frame #21: 0x00007fff8d09903e AppKit`-[NSView _layoutSubtreeWithOldSize:] + 870
frame #22: 0x00007fff8d09903e AppKit`-[NSView _layoutSubtreeWithOldSize:] + 870
frame #23: 0x00007fff8d09903e AppKit`-[NSView _layoutSubtreeWithOldSize:] + 870
frame #24: 0x00007fff8d09903e AppKit`-[NSView _layoutSubtreeWithOldSize:] + 870
frame #25: 0x00007fff8d07e584 AppKit`-[NSView layoutSubtreeIfNeeded] + 883
frame #26: 0x00007fff8d746688 AppKit`_NSViewLayoutSubtreesThatUseAutolayoutIfNeeded + 71
frame #27: 0x00007fff8d1097d1 AppKit`-[NSWindow(NSConstraintBasedLayout) _layoutViewTree] + 84
frame #28: 0x00007fff8d139d9d AppKit`-[NSWindow(NSConstraintBasedLayout) layoutIfNeeded] + 214
frame #29: 0x00007fff8d139c86 AppKit`-[NSView _layoutAtWindowLevelIfNeeded] + 80
frame #30: 0x00007fff8d13c3c3 AppKit`-[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 48
frame #31: 0x00007fff8d11c2fa AppKit`-[NSView displayIfNeeded] + 1680
frame #32: 0x00007fff8d18174e AppKit`_handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 884
frame #33: 0x00007fff8d757061 AppKit`__83-[NSWindow _postWindowNeedsDisplayOrLayoutOrUpdateConstraintsUnlessPostingDisabled]_block_invoke1331 + 46
frame #34: 0x00007fff904efe17 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
frame #35: 0x00007fff904efd87 CoreFoundation`__CFRunLoopDoObservers + 391
frame #36: 0x00007fff904e1468 CoreFoundation`__CFRunLoopRun + 776
frame #37: 0x00007fff904e0f25 CoreFoundation`CFRunLoopRunSpecific + 309
frame #38: 0x00007fff91192a0d HIToolbox`RunCurrentEventLoopInMode + 226
frame #39: 0x00007fff91192685 HIToolbox`ReceiveNextEventCommon + 173
frame #40: 0x00007fff911925bc HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 65
frame #41: 0x00007fff8cfe526e AppKit`_DPSNextEvent + 1434
frame #42: 0x00007fff8cfe48bb AppKit`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
frame #43: 0x00007fff8cfd89bc AppKit`-[NSApplication run] + 553
frame #44: 0x00007fff8cfc37a3 AppKit`NSApplicationMain + 940
frame #45: 0x0000000100007f02 Allocator`main(argc=7, argv=0x00007fff5fbff7f8) + 34 at main.m:13
4

0 回答 0