码迷,mamicode.com
首页 > 其他好文 > 详细

collectionView 防止cell复用的方法

时间:2017-05-24 09:56:49      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:orm   color   pat   dex   logs   nbsp   eid   sub   mat   

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];
        }
        
    }

 

collectionView 防止cell复用的方法

标签:orm   color   pat   dex   logs   nbsp   eid   sub   mat   

原文地址:http://www.cnblogs.com/-yun/p/6897352.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!