之前项目里一直有个iOS8 [UIScrollView(UIScrollViewInternal) _notifyDidScroll] crash的问题,存在了很久,后来复现问题,返现是动画执行过程中执行pop 的问题
场景:在商品详情页加车之后 做了滑动到下面的商品推荐位置, 当动画还没有执行完毕, 就POP回上个页面,就会发生如下Crash
参考文档 https://stackoverflow.com/questions/26103756/uiscrollview-internal-consistency-crash
Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x195287bdc objc_msgSend + 28
1 UIKit 0x18876fbbc -[UIScrollView(UIScrollViewInternal) _notifyDidScroll] + 72
2 UIKit 0x1884acdb4 -[UIScrollView setContentOffset:] + 500
3 UIKit 0x188562a98 -[UITableView setContentOffset:] + 300
4 UIKit 0x188646234 -[UIAnimator(Static) _advanceAnimationsOfType:withTimestamp:] + 316
5 QuartzCore 0x187e2629c CA::Display::DisplayLinkItem::dispatch() + 32
6 QuartzCore 0x187e26134 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 324
7 IOKit 0x184c01470 IODispatchCalloutFromCFMessage + 376
8 CoreFoundation 0x1839f2dc4 __CFMachPortPerform + 180
9 CoreFoundation 0x183a07a54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
10 CoreFoundation 0x183a079b4 __CFRunLoopDoSource1 + 436
11 CoreFoundation 0x183a05934 __CFRunLoopRun + 1640
12 CoreFoundation 0x1839312d4 CFRunLoopRunSpecific + 396
13 GraphicsServices 0x18d1476fc GSEventRunModal + 168
14 UIKit 0x1884f6fac UIApplicationMain + 1488
15 ZZKKO 0x100393c74 main (main.m:16)
16 libdyld.dylib 0x1958f2a08 start + 4
原因: iOS8系统下 ViewController被 控制器pop出堆栈以后 ,tableView 已经被release掉,但是 代理方法 仍旧会试图调用 send 消息 到 它的delegate方法。
解决办法
- (void)dealloc {
self.tableView.delegate = nil;
self.tableView.dataSource = nil;
}
原文地址:https://www.cnblogs.com/10-19-92/p/9340711.html