代码之家  ›  专栏  ›  技术社区  ›  MCMatan

崩溃:[NSCollectionViewData layoutAttributesForItemAtIndexPath]

  •  5
  • MCMatan  · 技术社区  · 7 年前

    Crashed: com.apple.main-thread
    EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000
    -[NSCollectionViewData layoutAttributesForItemAtIndexPath:]
    
    Crashed: com.apple.main-thread
    0  UIFoundation                   0x7fff7ac71c6a -[NSCollectionViewData layoutAttributesForItemAtIndexPath:] + 72
    1  UIFoundation                   0x7fff7ac3cb52 -[_NSCollectionViewCore _updateVisibleCellsNow:] + 7748
    2  UIFoundation                   0x7fff7ac358a9 -[_NSCollectionViewCore _layoutItems] + 298
    3  AppKit                         0x7fff5019dbc2 -[NSCollectionView layout] + 360
    4  AppKit                         0x7fff5002e755 _NSViewLayout + 587
    5  AppKit                         0x7fff5002e0fc -[NSView _layoutSubtreeWithOldSize:] + 446
    6  AppKit                         0x7fff5002e375 -[NSView _layoutSubtreeWithOldSize:] + 1079
    7  AppKit                         0x7fff5002e375 -[NSView _layoutSubtreeWithOldSize:] + 1079
    8  AppKit                         0x7fff5002e375 -[NSView _layoutSubtreeWithOldSize:] + 1079
    9  AppKit                         0x7fff5002e375 -[NSView _layoutSubtreeWithOldSize:] + 1079
    10 AppKit                         0x7fff5002e375 -[NSView _layoutSubtreeWithOldSize:] + 1079
    11 AppKit                         0x7fff5002e375 -[NSView _layoutSubtreeWithOldSize:] + 1079
    12 AppKit                         0x7fff5002e375 -[NSView _layoutSubtreeWithOldSize:] + 1079
    13 AppKit                         0x7fff5002bb96 -[NSView _layoutSubtreeIfNeededAndAllowTemporaryEngine:] + 1358
    14 AppKit                         0x7fff5002b332 -[NSWindow(NSConstraintBasedLayout) _layoutViewTree] + 148
    15 AppKit                         0x7fff5003cfee -[NSWindow(NSConstraintBasedLayout) layoutIfNeeded] + 263
    16 AppKit                         0x7fff50041469 -[NSWindow displayIfNeeded] + 180
    17 AppKit                         0x7fff5004130f __NSWindowGetDisplayCycleObserverForDisplay_block_invoke + 722
    18 AppKit                         0x7fff5003c41a NSDisplayCycleObserverInvoke + 170
    19 AppKit                         0x7fff5003bf8f NSDisplayCycleFlush + 1073
    20 QuartzCore                     0x7fff5d9621d3 CA::Transaction::run_commit_handlers(CATransactionPhase) + 49
    21 QuartzCore                     0x7fff5d961b9a CA::Transaction::commit() + 186
    22 AppKit                         0x7fff5003b8f5 __65+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayRefresh]_block_invoke + 274
    23 CoreFoundation                 0x7fff52a3f95d __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    24 CoreFoundation                 0x7fff52a3f892 __CFRunLoopDoObservers + 452
    25 CoreFoundation                 0x7fff529e13c5 __CFRunLoopRun + 1166
    26 CoreFoundation                 0x7fff529e0ce4 CFRunLoopRunSpecific + 463
    27 HIToolbox                      0x7fff51c7a895 RunCurrentEventLoopInMode + 293
    28 HIToolbox                      0x7fff51c7a5cb ReceiveNextEventCommon + 618
    29 HIToolbox                      0x7fff51c7a348 _BlockUntilNextEventMatchingListInModeWithFilter + 64
    30 AppKit                         0x7fff4ff3795b _DPSNextEvent + 997
    31 AppKit                         0x7fff4ff366fa -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
    32 AppKit                         0x7fff4ff3075d -[NSApplication run] + 699
    33 AppKit                         0x7fff4ff1fe97 NSApplicationMain + 780
    34 TodoDock                       0x105173a99 main (AppDelegate.swift:18)
    35 libdyld.dylib                  0x7fff7fa7a085 start + 1
    

    我甚至找到了一个有同样问题的人,在他的机器上安装了Xcode,并在本地运行相同的版本,一切都正常! 不仅如此,在我下载之后,下载的应用程序也起了作用!这太奇怪了,我真的不知道发生了什么事。 越来越多的用户将此过期,但不是所有用户。

    1 回复  |  直到 7 年前
        1
  •  6
  •   mouseymaniac    7 年前

    可能的原因:

    1. 具有不同大小的CollectionViewItem

    2. 甚至在加载视图之前调用viewFor()(在切换、更改或编辑视图时发生)

    我通过添加if条件来检查集合视图是否为nil来修复它。还可以检查更改视图时数据源numberOfItems是否一致。

        2
  •  0
  •   I make my mark    5 年前