遇到一个问题,在iOS 9.3下报错
UMengAnalytics<5.5.0>(Debug):[UMANError:62]UMAnalytics error:session_id=D61281EBB2DFE57A53CA9C373D4A904E, context=An instance 0x134af8800 of class UICollectionView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x135dd6210> (
<NSKeyValueObservance 0x135dd61e0: Observer: 0x135dd4e30, Key path: scrolling, Options: <New: NO, Old: YES, Prior: NO> Context: 0x0, Property: 0x135dd4a60>
)
key value observer没有被释放掉,开启查找bug模式。。。
有人说是MJRefresh的问题,经过一顿验证,并不是它的问题。
再仔细看看错误信息,发现Key path: scrolling,项目里搜索一下scrolling,找到了注册Y-Y
[_mainView addObserver:self forKeyPath:@"scrolling" options:NSKeyValueObservingOptionOld context:nil];
原来是TabBar里的主页面上的banner图注册的kvo没有被释放。
那在dealloc的时候调用一下removeObserver。
[_mainView removeObserver:self forKeyPath:@"scrolling"];
OK,解决
仔细查看错误信息,避免走弯路~~~