【发布时间】:2023-03-23 17:26:01
【问题描述】:
我在我的应用程序上使用自定义 UICollectionView。但是,我有一个问题导致我的应用程序崩溃。崩溃日志:
注意:iOS 8 上不会出现此错误
2015-05-29 11:49:26.316 app9to5[1834:607] Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView recieved layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0x7fca0e00> {length = 2, path
= 0 - 14}'
> First throw call stack: (
CoreFoundation 0x039b61e4 __exceptionPreprocess + 180
libobjc.A.dylib 0x036808e5 objc_exception_throw + 44
CoreFoundation 0x039b6048 +[NSException raise:format:arguments:] + 136
Foundation 0x016954de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
UIKit 0x02be0866 __45-[UICollectionViewData validateLayoutInRect:]_block_invoke + 1793
UIKit 0x02bdfaed -[UICollectionViewData validateLayoutInRect:] + 1376
UIKit 0x02ba5603 -[UICollectionView layoutSubviews] + 173
UIKit 0x025c8964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
libobjc.A.dylib
请帮我解决。非常感谢!
【问题讨论】:
-
你能给我一些你的代码,特别是你的布局属性设置函数和你的collectionview委托吗?
-
@EugeneNguyen:您可以在链接gist.github.com/cuong-nguyen-ta/5b7f73f2fb9a316ffcf5 中查看此代码,我认为它发生在我打电话给
[self.collectionView reloadData];时 -
@EugeneNguyen 这是功能设置布局属性gist.github.com/cuong-nguyen-ta/22f6d7c5039d3743a4f1请帮我解决。非常感谢!
-
有关此错误的更多信息。我在日志屏幕中看到 015-05-29 19:57:18.772 app9to5[2464:607] *** Assertion failure in -[UICollectionViewData validateLayoutInRect:], /SourceCache/UIKit_Sim/UIKit-2935.137/UICollectionViewData.m:357 /跨度>
-
您应该检查布局约束出口。约束出口之一可以为零。
标签: ios objective-c ios7 uicollectionview