swift – 崩溃:[NSCollectionViewData layoutAttributesForItem
发布时间:2020-12-14 04:43:24 所属栏目:百科 来源:网络整理
导读:现在试着了解这次崩溃. 对于某些用户(随机,操作系统10.14 / 10.14.1),应用程序在第一次加载时崩溃. Crashed: com.apple.main-threadEXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000-[NSCollectionViewData layoutAttributesForItemAtIndexPath:]Cra
现在试着了解这次崩溃.
对于某些用户(随机,操作系统10.14 / 10.14.1),应用程序在第一次加载时崩溃. 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并在本地运行相同版本,一切正常! 解决方法
我在开始时遇到了同样的随机崩溃问题.
可能的原因: > CollectionViewItem具有不同的大小 我通过添加if条件来修复它,以检查集合视图是否为零.还可以通过在更改视图时检查数据源numberOfItems是否一致. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |