UICollectionView 崩溃

War*_*Ali 5 xcode objective-c ios uicollectionview ios12

再会,

我无法复制崩溃,但我的几个在线用户遇到了崩溃。从 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
Run Code Online (Sandbox Code Playgroud)

小智 -1

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

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