首页 > 其他 > 详细

UICollectionView的cell创建直接从第三个数据开始问题

时间:2017-10-31 18:32:32      阅读:296      评论:0      收藏:0      [点我收藏+]

实现的效果是这样



大概意思就是第一组没有数据就直接将改组的cell高度变成0
效果实现了,但是第二组数据创建cell就出问题了--奇葩问题



* 代码问题在这
```
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    
    if (indexPath.section == 0) {
        
        if (self.couponDataArr.count) {
            return CGSizeMake(SCREEN_WIDTH, AUTO_SCALE_H(103));
        }else{
            
            return CGSizeMake(SCREEN_WIDTH, 0);
        }

    }else if(indexPath.section == 1){
        return CGSizeMake((MainScreenWidth- 10)/2, (MainScreenWidth- 10)/2+98);
    }else{
        return CGSizeZero;
    }
}
```


##就这样加个.1就好了



```
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    
    if (indexPath.section == 0) {
        
        if (self.couponDataArr.count) {
            return CGSizeMake(SCREEN_WIDTH, AUTO_SCALE_H(103));
        }else{
            
            return CGSizeMake(SCREEN_WIDTH, 0.1);
        }

    }else if(indexPath.section == 1){
        return CGSizeMake((MainScreenWidth- 10)/2, (MainScreenWidth- 10)/2+98);
    }else{
        return CGSizeZero;
    }
}


```
三张图,应该很是明了

UICollectionView的cell创建直接从第三个数据开始问题

原文:http://www.cnblogs.com/widgetbox/p/7762790.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!