zoukankan      html  css  js  c++  java
  • collectionView 防止cell复用的方法

    collectionView 防止cell复用的方法
    一:
    //在创建collectionView的时候注册cell(一个分区)
    
    UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@“cell" forIndexPath:indexPath];
    
        for (UIView *view in cell.contentView.subviews) {
    
            [view removeFromSuperview];
    
        }
    
    
    
    二:
    
    //在cellForItem方法中注册cell(多个分区)
    
     NSString *identifier=[NSString stringWithFormat:@"%ld%ld",(long)indexPath.section,(long)indexPath.row];
        
        [collect registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:identifier];
        
        UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
        
        for(id subView in cell.contentView.subviews){
            
            if(subView){
                
                [subView removeFromSuperview];
            }
            
        }
  • 相关阅读:
    12迭代器
    11(2)Vector(向量)
    11(1) LinkList ---链表
    11集合(Collection<E>) Arraylist
    10异常
    乘法计算过程的模拟
    10 Date详解
    详细的OA系统学习
    8 math类
    Java开发中的23种设计模式详解
  • 原文地址:https://www.cnblogs.com/-yun/p/6897352.html
Copyright © 2011-2022 走看看