![swift – 崩溃:[NSCollectionViewData layoutAttributesForItemAtIndexPath],第1张 swift – 崩溃:[NSCollectionViewData layoutAttributesForItemAtIndexPath],第1张](/aiimages/swift+%E2%80%93+%E5%B4%A9%E6%BA%83%EF%BC%9A%5BNSCollectionViewData+layoutAttributesForItemAtIndexPath%5D.png)
对于某些用户(随机, *** 作系统10.14 / 10.14.1),应用程序在第一次加载时崩溃.
Crashed: com.apple.main-threadEXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000-[NSCollectionVIEwData layoutAttributesForItemAtIndexPath:]Crashed: com.apple.main-thread0 UIFoundation 0x7fff7ac71c6a -[NSCollectionVIEwData layoutAttributesForItemAtIndexPath:] + 721 UIFoundation 0x7fff7ac3cb52 -[_NSCollectionVIEwCore _updateVisibleCellsNow:] + 77482 UIFoundation 0x7fff7ac358a9 -[_NSCollectionVIEwCore _layoutItems] + 2983 AppKit 0x7fff5019dbc2 -[NSCollectionVIEw layout] + 3604 AppKit 0x7fff5002e755 _NSVIEwLayout + 5875 AppKit 0x7fff5002e0fc -[NSVIEw _layoutSubtreeWitholdSize:] + 4466 AppKit 0x7fff5002e375 -[NSVIEw _layoutSubtreeWitholdSize:] + 10797 AppKit 0x7fff5002e375 -[NSVIEw _layoutSubtreeWitholdSize:] + 10798 AppKit 0x7fff5002e375 -[NSVIEw _layoutSubtreeWitholdSize:] + 10799 AppKit 0x7fff5002e375 -[NSVIEw _layoutSubtreeWitholdSize:] + 107910 AppKit 0x7fff5002e375 -[NSVIEw _layoutSubtreeWitholdSize:] + 107911 AppKit 0x7fff5002e375 -[NSVIEw _layoutSubtreeWitholdSize:] + 107912 AppKit 0x7fff5002e375 -[NSVIEw _layoutSubtreeWitholdSize:] + 107913 AppKit 0x7fff5002bb96 -[NSVIEw _layoutSubtreeIfNeededAndAllowTemporaryEngine:] + 135814 AppKit 0x7fff5002b332 -[NSWindow(NSConstraintBasedLayout) _layoutVIEwTree] + 14815 AppKit 0x7fff5003cfee -[NSWindow(NSConstraintBasedLayout) layoutIfNeeded] + 26316 AppKit 0x7fff50041469 -[NSWindow displayIfNeeded] + 18017 AppKit 0x7fff5004130f __NSWindowGetdisplayCycleObserverFordisplay_block_invoke + 72218 AppKit 0x7fff5003c41a NSdisplayCycleObserverInvoke + 17019 AppKit 0x7fff5003bf8f NSdisplayCycleFlush + 107320 QuartzCore 0x7fff5d9621d3 CA::Transaction::run_commit_handlers(CATransactionPhase) + 4921 QuartzCore 0x7fff5d961b9a CA::Transaction::commit() + 18622 AppKit 0x7fff5003b8f5 __65+[CATransaction(NSCATransaction) NS_setFlushesWithdisplayRefresh]_block_invoke + 27423 CoreFoundation 0x7fff52a3f95d __CFRUNLOOP_IS_CALliNG_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 2324 CoreFoundation 0x7fff52a3f892 __CFRunLoopDoObservers + 45225 CoreFoundation 0x7fff529e13c5 __CFRunLoopRun + 116626 CoreFoundation 0x7fff529e0ce4 CFRunLoopRunspecific + 46327 HIToolBox 0x7fff51c7a895 runcurrentEventLoopInMode + 29328 HIToolBox 0x7fff51c7a5cb ReceiveNextEventCommon + 61829 HIToolBox 0x7fff51c7a348 _BlockUntilNextEventMatchingListInModeWithFilter + 6430 AppKit 0x7fff4ff3795b _DPSNextEvent + 99731 AppKit 0x7fff4ff366fa -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 136232 AppKit 0x7fff4ff3075d -[NSApplication run] + 69933 AppKit 0x7fff4ff1fe97 NSApplicationMain + 78034 TodoDock 0x105173a99 main (AppDelegate.swift:18)35 libdyld.dylib 0x7fff7fa7a085 start + 1
从它的外观来看,似乎应用程序还没有事件加载.
我甚至设法找到一个有同样问题的人,在他的机器上安装Xcode并在本地运行相同版本,一切正常!
不仅如此,我做了之后,下载的应用程序也工作了!这太奇怪了,我真的不知道发生了什么.
更多的用户正在宣传这一点,但不是全部.
可能的原因:
> CollectionVIEwItem具有不同的大小
>视图加载前调用的vIEwFor()(切换或更改或编辑视图时发生)
>编辑影响其他集合视图项的一个集合视图项的大小(如果删除前者,则可能)
我通过添加if条件来修复它,以检查集合视图是否为零.还可以通过在更改视图时检查数据源numberOfItems是否一致.
总结以上是内存溢出为你收集整理的swift – 崩溃:[NSCollectionViewData layoutAttributesForItemAtIndexPath]全部内容,希望文章能够帮你解决swift – 崩溃:[NSCollectionViewData layoutAttributesForItemAtIndexPath]所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)