UICollectionViewFlowLayout subclass crashes accessing array beyond bounds while scrolling and reloading

后端 未结 4 2021
小蘑菇
小蘑菇 2021-02-03 14:16

I have a UICollectionView that uses a custom subclass of UICollectionViewFlowLayout to make the section headers stick to the top of the screen while scrolling just like UITableV

4条回答
  •  一整个雨季
    2021-02-03 14:45

    I have same problem. and I fixed it.

    __weak typeof(self) weakSelf = self;
    UICollectionView *collectionView = self.collectionView;
    [UIView performWithoutAnimation:^{
        [collectionView performBatchUpdates:^{
            collectionView.collectionViewLayout = layout;
        } completion:^(BOOL finished) {
            __strong typeof(self) strongSelf = weakSelf;
            if (strongSelf){
                [strongSelf reloadThumbData];
            }
        }];
    }];
    

提交回复
热议问题