UICollectionViewController的使用
2015-11-11 08:38
435 查看
重写init方法,创建布局参数- (id)init
{
[[UICollectionViewFlowLayout alloc] init];// 2.每个cell的尺寸
layout.itemSize = CGSizeMake(100, 100); return [super initWithCollectionViewLayout:layout];
}
注册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; }
• UICollectionViewFlowLayout称为”流水布局”,用来约束cell的显示
• 常见属性
➢
Cell的尺寸
@property
(nonatomic)
CGSize
itemSize;
➢ cell之间的水平间距
@property
(nonatomic)
CGFloat
minimumInteritemSpacing;
➢ cell之间的垂直间距
@property
(nonatomic)
CGFloat
minimumLineSpacing;
➢ 四周的内边距
@property
(nonatomic)
UIEdgeInsets
sectionInset;
相关文章推荐
- iOS开发之UITabBarController和UICollectionView的使用
- UICollectionViewController的使用详解,相册滚动偏移放大
- UICollectionViewController使用,pushViewController弹出时
- iOS开发之窥探UICollectionViewController(三) --使用UICollectionView自定义瀑布流
- UICollectionViewController的使用
- iOS开发之窥探UICollectionViewController(三) --使用UICollectionView自定义瀑布流
- Storyboard创建使用UICollectionViewController
- iOS彩票项目--第四天,新特性界面搭建,UICollectionViewController的初次使用
- UICollectionViewController使用问题之UICollectionViewFlowLayout
- iOS开发之UITabBarController和UICollectionView的使用
- Storyboard创建使用UICollectionViewController
- UICollectionViewController的使用
- 2015/10/21 UICollectionViewController 使用
- UIWebView和UICollectionViewController的使用
- Storyboard创建使用UICollectionViewController
- iOS开发之UICollectionViewController系列(三) :使用UICollectionView自定义瀑布流
- iOS UICollectionViewController基本使用方法和简单的相册实现
- iOS学习笔记6- iOS UICollectionView简单使用
- 自定义UICollectionViewController…
- UICollectionView官方使用示例代码研究