SoFunction
Updated on 2025-03-04

Two ways to prevent reuse from IOS collectionViewCell

Two ways to prevent reuse from IOS collectionViewCell

CollectionView Method 1 to prevent cell reuse:

//Register cell (a partition) when creating a collectionView
UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@“cell" forIndexPath:indexPath];

  for (UIView *view in ) {

    [view removeFromSuperview];

  }



collectionView method to prevent cell reusetwo:

//Register cell (multiple partitions) in cellForItem method
 NSString *identifier=[NSString stringWithFormat:@"%ld%ld",(long),(long)];

  

  [collect registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:identifier];

  

  UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];

  

  for(id subView in ){

    

    if(subView){

      

      [subView removeFromSuperview];

    }

    

  }

Thank you for reading, I hope it can help you. Thank you for your support for this site!