1.新建一个xib描述UICollectionViewCell(比如DealCell.xib),设置好resuse identifier(比如deal)

2.控制器继承UICollectionViewController

1> 注册xib

[self.collectionView registerNib:[UINib nibWithNibName:@"DealCell" bundle:nil] forCellWithReuseIdentifier:@"deal"];

2> 重写init方法

- (id)init

{

UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];

// 每一个网格的尺寸

layout.itemSize = CGSizeMake(250, 250);

// 每一行之间的间距

layout.minimumLineSpacing = 20;

// 上下左右的间距

layout.sectionInset = UIEdgeInsetsMake(10, 20, 40, 80);     return [self initWithCollectionViewLayout:layout];

}

3> 实现数据源方法

#pragma mark 每一组有多少个条目(格子)

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section

#pragma mark 每一个格子显示什么样的cell

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

3.UICollectionViewFlowLayout的常见设置

1> CGFloat minimumLineSpacing:每一行之间的间距

2> UIEdgeInsets sectionInset:上下左右周边的间距

3> CGSize itemSize:每一个网格的大小

4.UICollectionView的设置

1> BOOL alwaysBounceVertical:永远支持垂直的弹簧效果(滚动效果,来自UIScrollView的属性)

5.UITableViewController和UICollectionViewController的区别

1> 在UITableViewController中:self.tableView == self.view

2> 在UICollectionViewController中:self.collectionView == self.view中的一个子控件

最新文章

  1. [leetcode] 47. Permutations II
  2. GC
  3. java new Date()得到的时间和系统时间不一样
  4. Android.mk相关知识
  5. restController与Controller-待续
  6. ORACLE ORA-01157: 无法标识/锁定数据文件
  7. 向Web开发人员推荐12款优秀的 Twitter Bootstrap 组件和工具
  8. OC基础--description方法
  9. Memcached笔记——(四)应对高并发攻击【转】
  10. Linux2.6内核--内存管理(2)--区
  11. 微设计(www.weidesigner.com)介绍系列文章(二)
  12. Zookeeper 4、Zookeeper开发
  13. 友坚恒天.开发板(Cotex-A9 Exynos4412 开发板)
  14. RPi Kernel Compilation
  15. AUTOSAR的前期开源实现Arctic Core
  16. python中 yield的用法和生成器generator的说明
  17. Find Common Characters LT1002
  18. 2.网络编程-udp
  19. Zabbix监控系统部署:前端初始化
  20. php开发APP接口(总结一)

热门文章

  1. POJ 2010
  2. DF学Mysql(一)——数据库基本操作
  3. SQL技术内幕-12 SQL优化方法论前言
  4. 无限互联IOS电影项目视频笔记
  5. SharePoint文档库文件大小限制(win2008+II7)问题
  6. vim 查看某字符串出现的次数
  7. c 从语言中的内存管理
  8. CentOS 7 中firewall-cmd命令
  9. CentOS7安装配置DNS服务器
  10. SSIS ->> 通过Checkoints实现SSIS的包重启(Package Restartability Fullfilled By Checkoints)