zoukankan      html  css  js  c++  java
  • UICollectionViewController的使用

    1. 注册cell(告诉collectionView将来要创建怎样的cell)

    [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"product"];

    2. 从缓存池中取出cell

    - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
    {
        UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"product" forIndexPath:indexPath];
    
        return cell;
    }

    3. 重写init方法,创建布局参数

    - (id)init
    {
        // 1.流水布局
            UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        // 2.每个cell的尺寸
            layout.itemSize = CGSizeMake(100, 100);
        return [super initWithCollectionViewLayout:layout];
    }
  • 相关阅读:
    typescript-定义静态类型和对象类型
    typescript-全局安装
    Cube-ui的使用
    mobx-react
    Calatan Number
    快速排序
    Boyer-Moore
    优先级队列
    PointNet环境搭建
    h5py库
  • 原文地址:https://www.cnblogs.com/cxios/p/4223199.html
Copyright © 2011-2022 走看看