【问题标题】:Crash on UICollectionViewUICollectionView 崩溃
【发布时间】:2019-06-15 19:59:47
【问题描述】:

早安,

我无法复制崩溃,但我的几个实时用户遇到了崩溃。下面是从 crashlytics 下载的崩溃报告。 有人可以帮忙吗?它发生在 iOS12 上的用户身上。

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x220ee4ec4 __exceptionPreprocess
1  libobjc.A.dylib                0x2200b5a40 objc_exception_throw
2  CoreFoundation                 0x220dfab3c +[_CFXNotificationTokenRegistration keyCallbacks]
3  Foundation                     0x2218e91d0 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4  UIKitCore                      0x24d55ed28 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:]
5  UIKitCore                      0x24d562e14 -[UICollectionView _updateVisibleCellsNow:]
6  UIKitCore                      0x24d567eb4 -[UICollectionView layoutSubviews]
7  UIKitCore                      0x24e13b96c -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
8  QuartzCore                     0x2254e1b74 -[CALayer layoutSublayers]
9  QuartzCore                     0x2254e6b2c CA::Layer::layout_if_needed(CA::Transaction*)
10 UIKitCore                      0x24e126e58 -[UIView(Hierarchy) layoutBelowIfNeeded]
11 UIKitCore                      0x24e12da08 +[UIView(Animation) performWithoutAnimation:]
12 UIKitCore                      0x24debd174 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:]
13 UIKitCore                      0x24debd4bc -[UITableView _createPreparedCellForGlobalRow:willDisplay:]
14 UIKitCore                      0x24de88b94 -[UITableView _updateVisibleCellsNow:isRecursive:]
15 UIKitCore                      0x24de894fc -[UITableView _updateVisibleCellsNow:isRecursive:]
16 UIKitCore                      0x24dea6a80 -[UITableView layoutSubviews]
17 UIKitCore                      0x24e13b96c -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
18 QuartzCore                     0x2254e1b74 -[CALayer layoutSublayers]
19 QuartzCore                     0x2254e6b2c CA::Layer::layout_if_needed(CA::Transaction*)
20 QuartzCore                     0x22544544c CA::Context::commit_transaction(CA::Transaction*)
21 QuartzCore                     0x225473d7c CA::Transaction::commit()
22 QuartzCore                     0x225474be4 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
23 CoreFoundation                 0x220e747cc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
24 CoreFoundation                 0x220e6f460 __CFRunLoopDoObservers
25 CoreFoundation                 0x220e6fa00 __CFRunLoopRun
26 CoreFoundation                 0x220e6f1f0 CFRunLoopRunSpecific
27 GraphicsServices               0x2230e8584 GSEventRunModal
28 UIKitCore                      0x24dc934c0 UIApplicationMain
29 Psychic Txt                    0x1020cd03c main (main.m:14)
30 libdyld.dylib                  0x22092ebb4 start

【问题讨论】:

  • 添加到集合视图时的单元格行为是什么?用户可以编辑行(插入/删除?)
  • 当应用程序接收到通过符合 XMPP 服务器的侦听器处理的通知时,会自动添加或删除行。当我测试应用程序时,这些行工作正常。我已经进行了 100 次测试,但一次无法复制。
  • hmm.. 在尝试插入/删除行但未正确更新数据源时,通常会抛出关于 _createPreparedCellForItemAtIndexPath 上的集合视图的 NSInternalInconsistencyException(不是 100% 确定是否有其他情况)。您能否发布如何在插入/删除时更新数据源?

标签: ios objective-c xcode uicollectionview ios12


【解决方案1】:

您的数据可能存在同步问题,并将插入和删除传播到集合视图。您需要确保在插入/删除单元格对 collectionview 进行更改时,您的数据源没有被修改。

这意味着如果您的侦听器想要更新您的数据,您需要确保之前的更改已被应用。您可以使用信号量来做到这一点。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多