【发布时间】:2013-10-18 11:22:41
【问题描述】:
我在使用 ios 7 的 UICollectionView 中遇到了奇怪的崩溃,当滚动速度非常快时往往会发生这种情况。此处的 Apple Developer Forms 报告了类似问题:https://devforums.apple.com/message/901009#901009
我想知道是否有人遇到过这种情况并找到了修复/解决方法?
我正在使用配置了流布局的基本 UICollection 视图。它是通过网络从 json 数据中填充的。数据周期性变化。当它调用reloadData 方法时。我已经检查以确保始终在主线程上调用 reload 方法,因为我担心我的网络回调之一是在后台线程上回调。 绝对不是这样的。
打开 NSZmobies 时,我在崩溃发生时收到以下日志消息:
*** -[NSIndexPath section]: message sent to deallocated instance 0x218b74c0
我还使用 Zombies 跟踪模板运行了附加到 Instruments 的应用程序,并且能够获得以下堆栈跟踪,详细说明导致崩溃的调用序列。
注意 所有调用都是 iOS 框架级别的调用,而不是我的应用程序调用。
0 libsystem_malloc.dylib malloc_zone_calloc
1 libsystem_malloc.dylib calloc
2 libobjc.A.dylib class_createInstance
3 libobjc.A.dylib +[NSObject allocWithZone:]
4 Foundation +[NSIndexPath indexPathWithIndexes:length:]
5 UIKit +[NSIndexPath(UITableView) indexPathForRow:inSection:]
6 UIKit -[UICollectionViewFlowLayout _layoutAttributesForItemsInRect:]
7 UIKit -[UICollectionViewFlowLayout layoutAttributesForElementsInRect:]
8 UIKit __45-[UICollectionViewData validateLayoutInRect:]_block_invoke
9 UIKit -[UICollectionViewData validateLayoutInRect:]
10 UIKit -[UICollectionView layoutSubviews]
11 UIKit -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
12 QuartzCore -[CALayer layoutSublayers]
13 QuartzCore CA::Layer::layout_if_needed(CA::Transaction*)
14 QuartzCore CA::Layer::layout_and_display_if_needed(CA::Transaction*)
15 QuartzCore CA::Context::commit_transaction(CA::Transaction*)
16 QuartzCore CA::Transaction::commit()
17 QuartzCore CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
18 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
19 CoreFoundation __CFRunLoopDoObservers
20 CoreFoundation CFRunLoopRunSpecific
21 CoreFoundation CFRunLoopRunInMode
22 GraphicsServices GSEventRunModal
23 UIKit UIApplicationMain
24 Mixlr main /Users/saman/Desktop/mixlr-iphone/Mixlr/main.m:14
25 libdyld.dylib start
【问题讨论】:
-
它在 iOS 6 及更早版本上运行良好吗?
-
我没有在 iOS 6 中测试过。
-
我觉得这和UICollectionView crash on unhighlightAllItems是一样的问题。
标签: ios objective-c crash uikit uicollectionview