有时在应用启动时设置collectionViewLayout会导致此致命异常:
您知道为什么吗?
没有更新,因为它是在应用程序启动期间。 而且我无法复制它。 我从Crashlytics那里崩溃了。
Fatal Exception: NSInternalInconsistencyException Cannot set the layout [<StreamContainerLayoutIPad: 0x1056a4e60>] for [<DMZFixedCollectionView: 0x10593f600; baseClass = UICollectionView; frame = (0 0; 375 667); clipsToBounds = YES; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x283906640>; layer = <CALayer: 0x2837dd1a0>; contentOffset: {0, 0}; contentSize: {0, 0}; adjustedContentInset: {0, 0, 0, 0}> collection view layout: <UICollectionViewLayout: 0x10566f620>] during an update.
Stacktrace:
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x183df7ea0 __exceptionPreprocess
1 libobjc.A.dylib 0x182fc9a40 objc_exception_throw
2 CoreFoundation 0x183d0dc1c +[_CFXNotificationTokenRegistration keyCallbacks]
3 Foundation 0x1847fb140 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4 UIKitCore 0x1b089ac4c -[UICollectionView _setCollectionViewLayout:animated:isInteractive:completion:animator:]
5 UIKitCore 0x1b089aaa8 -[UICollectionView _setCollectionViewLayout:animated:isInteractive:completion:]
6 UIKitCore 0x1b089a668 -[UICollectionView setCollectionViewLayout:]
7 Vero 0x1048f52e4 -[StreamCompressionController setup] (__hidden#27104_:77)
8 Vero 0x10491d0ac -[StreamMainViewController viewWillAppear:] (__hidden#26011_:227)
9 UIKitCore 0x1b0a038ec -[UIViewController _setViewAppearState:isAnimating:]
10 UIKitCore 0x1b0a03fd0 -[UIViewController __viewWillAppear:]
这是我在设置方法中的代码:
- (void)setup
{
CollectionLayout *newLayout = [self createLayout];
_collectionView.collectionViewLayout = newLayout;
_layout = newLayout;
}
PS:奇怪的是,仅在iPhone上发生,而在iPad上没有发生。