zoukankan      html  css  js  c++  java
  • UICollectionView的cell创建直接从第三个数据开始问题

    实现的效果是这样



    大概意思就是第一组没有数据就直接将改组的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;
        }
    }


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

  • 相关阅读:
    有赞个性化推荐能力的演进与实践
    Doge.jpg 的背后是什么,你知道么?
    实操|如何将 Containerd 用作 Kubernetes runtime
    Linux 用键盘操作窗口
    Oracle中join left,join right,inner join,(+) 等
    sql之left join、right join、inner join的区别
    SQL中GROUP BY的用法
    Oracle CASE WHEN 用法介绍
    Oracle数据库面试题
    Oracle笔试题库之问答题篇-总共60道
  • 原文地址:https://www.cnblogs.com/widgetbox/p/7762790.html
Copyright © 2011-2022 走看看