学习IOS开发UI篇--UICollectionViewController的基本使用

  1. UICollectionViewController,必须传入一个非空的layout的参数,在初始化init方法self =[super initWithCollectionViewLayout:layout]

  2.在加载代码或Xib时,需调用[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:NJIdentifier],或[self.collectionView registerNib:nib forCellWithReuseIdentifier:NJIdentifier];

  3.在- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath方法中调用Cell = [collectionView dequeueReusableCellWithReuseIdentifier:NJIdentifier forIndexPath:indexPath];会在缓存池中寻找对应的Cell.

原文地址:https://www.cnblogs.com/zhaoyan/p/3803010.html