iOS17 UICollectionView 崩溃解决

Thread 1: "UICollectionView internal inconsistency: attempted to set layout with the collection view requiring a reload. Collection view: <UICollectionView: 0x1071c0200; frame = (0 0; 1080 810); clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x2813a0cc0>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x281c7c240>; contentOffset: {0, 0}; contentSize: {0, 0}; adjustedContentInset: {0, 0, 0, 0}; layout: <UICollectionViewFlowLayout: 0x106ef5760>; dataSource: <GHControlVc: 0x1078acc00>>"

解决方法-Latout设置要在代理设置之前

之前设置

    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    self.collectionView.collectionViewLayout = [self collecitonViewLayout];

改为

    self.collectionView.collectionViewLayout = [self collecitonViewLayout];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容